Can someone help me with the script?
Player should be able to jump with space bar, it was working but now our player is jumping and not returning.
https://playcanvas.com/editor/scene/2200439
here is script:
Can someone help me with the script?
Player should be able to jump with space bar, it was working but now our player is jumping and not returning.
https://playcanvas.com/editor/scene/2200439
here is script:
Hi @Ashley_Solano!
I see Linear Damping of the rigidbody component is set to zero, so maybe the jump power is just too much?
Or maybe Linear Damping should not be set to zero.
Made a fork to confirm, its not that. The issue is actually using the setTimeout() function causing odd behavior.
The issue can be solved by removing the setTimeout function and replacing it with:
this.entity.rigidbody.applyImpulse(0, this.jumpPower, 0);
Ah I see, probably because this.jumpPower
is undefined in the time out. In this case self.jumpPower
should be used instead.
thank you! This worked, but now our player can only jump once instead of anytime space is pressed.
Any suggestions?
Thanks for the help!
As far I can see on my mobile, the entity that has the ‘ground’ tag is currently part of the player entity. I don’t know your logic, but this doesn’t look correct to me.