How to make my controller jump when only on ground and not the walls?
My controller can only jump when it touches something so it won't jump when it's in the air. But it still can jump when it touches a wall or something vertical like that. I need my controller to only be able to jump when it touches horizontal ground.
void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
GetComponent<Rigidbody> ().AddForce (movement * speed * Time.deltaTime);
{
if (Input.GetKeyDown ("space") && (grounded == true ) ) {
Vector3 jump = new Vector3 (0.0f, 180.0f, 0.0f);
GetComponent<Rigidbody> ().AddForce (jump);
Comment