Reputation: 63
While searching for this solution, I noticed many used, cannonBody.velocity.y = JUMP_VELOCITY
But in my case, It works while the object is already in motion but not once it became stationary. So, I was wondering if there are a few conditions to be met for it to jump.
I would also encourage a demo snippet of making a simple object (a ball) to jump when the spacebar is pressed.
Upvotes: 1
Views: 840
Reputation: 157
I switched to OimoPhysics and things woke up properly. It uses the same conventions. How it replaces the physics world in a declarative setup, I don't know..? I've done that with Canon, where you set the config tolerance. But even with the quick setup where you just add a body or move it, Oimo solved the sleep problem immediately. ApplyForce would be more consistent and realistic than an arbitrary + y value. I think applyForce would give less problems.
It's easy to forget to call update on the physics after you move the geometry. If the render loop misses a step your geometry may be frozen, lost to the physics body. Or if you add another physics body in its place the original pointer may be lost. Then if another body collides it will suddenly wake up. It depends on the circumstances and the version...
Upvotes: 2