Search Unity

CS0106 The modifier 'private' is not valid for this item

Discussion in 'Scripting' started by wienerfrog, May 15, 2020.

  1. wienerfrog

    wienerfrog

    Joined:
    May 15, 2020
    Posts:
    3
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerController : MonoBehaviour
    6. {
    7.  
    8.  
    9.     Rigidbody2D rb;
    10.  
    11.  
    12.     [SerializeField]
    13.     float jumpForce;
    14.  
    15.     bool grounded;
    16.  
    17.     private void Awake()
    18.     {
    19.         rb = GetComponent<Rigidbody2D>();
    20.     }
    21.  
    22.  
    23.  
    24.     // Update is called once per frame
    25.     void Update()
    26.     {
    27.         if (Input.GetMouseButtonDown(0))
    28.         {
    29.             if (grounded)
    30.             {
    31.  
    32.                 Jump();
    33.             }
    34.  
    35.         }
    36.  
    37.         void Jump()
    38.         {
    39.             grounded = false;
    40.  
    41.             rb.velocity = Vector2.up * jumpForce;
    42.         }
    43.  
    44.  
    45.         private void OnCollisionEnter2D(Collision2D collision)
    46.      
    47.         {
    48.             if (collision.gameObject.tag == "Ground")
    49.             {
    50.                 grounded = true;
    51.             }
    52.         }
    53.  
    54. }   }
    55.  
    I can't seem to figure out what's wrong with this code. I checked and can't see any } errors or anything, but i'm new so maybe I'm missing something.