hi,I would like to know how can I make character jump in an endless runner genre?
public int jumpForce= 50;
private bool canJump;
private RigidBody rb;
void Start()
{
rb = GetComponent<RigidBody>();
}
void FixedUpdate()
{
if(canJump){
canJump = false;
rb.addForce(0, jumpForce, 0, ForceMode.Impulse);
}
}
void Update()
{
if(Input.GetKeyUp(Keycode.SPACE)){
canJump = true;
}
}