So it is saying that ‘Private’ modifier is not valid for this item. I’m just getting into C# and have no clue what is wrong with what i have. Any help would be appreciated.
heres the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
public LayerMask groundLayers;
public float forwardForce = 500f;
public float speed = 5;
public float jumpForce = 7;
private Rigidbody rb;
private CubeCollider col;
#region Monobehaviour API
void Start()
{
rb = GetComponent<Rigidbody>();
col = GetComponent<CubeCollider>();
}
void Update()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);
rb.AddForce(movement * speed);
if (IsGrounded() && Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
if (Input.GetKeyDown("c"))
{
rb.AddForce(0, JumpForce * Time.deltaTime, 0);
}
if (Input.GetKey("w"))
{
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
}
if (Input.GetKey("d"))
{
rb.AddForce(forwardForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("a"))
{
rb.AddForce(-forwardForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("s"))
{
rb.AddForce(0, 0, -forwardForce * Time.deltaTime);
}
}
private bool IsGrounded()
{
return Physics.CheckCapsule(col.bounds.center, new Vector3(col.bounds.center.x, col.bounds.min.y, col.bounds.center.z), col.radius * .9f, groundLayers);
}
#endregion