void HeroJumpMode(){
if (onGround){
//Move forward as 30, force to move down as -30)
body2d.velocity = new Vector2(30, -30);
if (Input.GetKey(KeyCode.Space) || (Input.GetMouseButtonUp(0))) {
asJumpSound.Play();
body2d.velocity = new Vector2(0, jumpSpeed);
//jump a hero forward
StartCoroutine(JumpForward());
}
}
}
My default input for jumping is using spacebar (tested several times) with no issue or whatsoever but when I tried using mouseclick, It create lag and delay for 0.5 to 2 sec. before executing jump command.
Need help… I’m not sure if this is a bug or the code is not correct.
most likely because you’re calling this from FixedUpdate (or at least you should be to use the AddForce function) and that doesn’t run every frame, so the instruction may be getting missed (since both those mouse functions are only valid in the frame they happen).