Question by
LouieSan · Nov 26, 2019 at 09:08 AM ·
scripting problemnavmeshnavmeshagentjumping object
How can I make a gameObject with a NavMeshAgent component jump using the space bar?
I've been trying to make the gameObject with a NavMeshAgent component jump using the following code:
private void OnCollisionStay(Collision collision)
{
playerOnGround = true;
}
public void PlayerJump()
{
if (Input.GetKeyDown(KeyCode.Space) && playerOnGround)
{
agent.enabled = false;
rigidbody.AddForce(Vector3.up * jumpHeight, , ForceMode.Impulse);
playerOnGround = false;
}
if (playerOnGround)
agent.enabled = true;
}
Its not working.
Comment