Herby Irons

Herby Irons

  • NA
  • 3
  • 681

Assets\Scripts\PlayerControl.cs(38,6): error CS0106

Dec 15 2022 6:23 PM

hi all. recently began to learn the language. when I was creating the game, I came across this error: Assets\Scripts\PlayerControl.cs(38,6): error CS0106: The modifier 'private' is not valid for this item 

My code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PlayerControl : MonoBehaviour
{
    public float speed;
    private float Move;
    public float jump;
    public bool Grounded = false;
    public Transform GroundCheck;
    public float GroundRadius = 0.2f;
    public LayerMask wtfIsGround;
    private Rigidbody2D rb;
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    void Update()
    {
        Grounded = Physics2D.OverlapCircle(GroundCheck.position, GroundRadius, wtfIsGround);
        Move = Input.GetAxis("Horizontal");
        rb.velocity = new Vector2(speed * Move, rb.velocity.y);
        if (Input.GetButtonDown("Jump") && Grounded)
        {
            rb.AddForce(new Vector2(rb.velocity.x, jump));
        }
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if(collision.tag == "NextLevel")
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
                respawnPoint = transform.position;
            }
            else if(collision.tag == "PreviousLevel")
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
                respawnPoint = transform.position;
            }
        }
    }
}