Detect rigidbody on ground: Y-part of velocity is never 0

Pacha
Posts: 26
Joined: Sat Jun 15, 2013 2:29 am

Detect rigidbody on ground: Y-part of velocity is never 0

Post by Pacha »

I am using Ogre, and to simulate jumping, I am checking if the Y-part of velocity is equal to 0 (is touching the ground).

The thing is that it is never 0, even if it is touching the ground. It is always a really small value.

What should I do to check if my rigidbody is on top another object? Thanks.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Detect rigidbody on ground: Y-part of velocity is never

Post by Basroil »

Try checking if |y|< epsilon, where epsilon will have to be a non-zero but very small number. Physics engines in general tend to have non-exact performance when dealing with non-exact solutions (like PGS in bullet). It's the same reason why stacking multiple boxes is difficult and often used to check engine stability.

Probably better to just check for contact using contact manifolds, raycasts, etc (again, some tolerance may be needed), since you can have non-contact zero velocity if you're bouncing off something (and falling back down).