I am trying to make a code that limits the player’s jumping ability to only when he is on the ground.
Code:
if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
distanceToGround = hit.distance;
}
if (Input.GetKeyDown(KeyCode.Space) && (hit.distance <= .5)){
rb.AddForce(Vector3.up*jumpForce);
}
Errors:
The best overloaded method match for ‘UnityEngine.Physics.Raycast(UnityEngine.Vector3, UnityEngne.Verctor3, out UnityEngine.RaycastHit)’ has some invalid arguments
Argument ‘#3’ is missing ‘out’ modifier