Game Development Community

Jump Animation Issue With Bullet Physics and Ground Plane

by Chad Hall · in Torque 3D Professional · 01/02/2014 (11:10 pm) · 1 replies

So, I've encountered a bit of an odd bug. Recently I was doing a lot of work with animations and in the process discovered that the player won't play the jump animation if they jumped when standing at a Z value below 0.02. I thought it was a problem with only my game being that I had changed so much but had an idea and went to check it on vanilla Torque3D.

Tested on both T3D 3.5 and 3.0 stock, only thing I changed was enabling Bullet Physics. The issue doesn't seem to occur without Bullet. If you jump while standing on a ground plane object or even when standing on another object that is on a ground plane -- as long as your Z is below 0.02 -- you won't play a jump animation. If you're moving the walk animation will get called right after the jump animation. If you're standing still the root animation gets called. Either way, the action animation is replaced and thus the jump animation doesn't play.

From what I can gather it's some kind of problem in the findContact function for Bullet used in player.cpp when determining a run/jump surface. I've tested this with both Gideon (the stock T3D model) and my own game's character model. The problem seems gone if you remove the ground plane from the game. I'll try to see if I can narrow this down further when I have time, otherwise I just wanted to post this in case it helps anyone.

Edit: Whoops, minimum value before jump works is 0.02, not 0.2. While I'm at it, I have looked into it a bit more and it does seem BtPlayer::findContact() is returning 1 contact object in the instances where the jump animation gets cancelled but none when it works - as expected.

Edit #2: Okay, so, this is interesting. Why is it that in non-Bullet builds of T3D when the player walks on a ground plane object their Z position is 0.02, but in Bullet builds it's -0.02? Since the contact info magically corrects itself when the player is over 0.02 that seems a bit too coincidental.

#1
01/03/2014 (9:09 am)
Okay, so, after searching through all the files for instances of 0.04 and 0.02 I found this line in btPersistentManifold.cpp:

btScalar gContactBreakingThreshold = btScalar(0.02);

Changing that value changes the minimum height before contact is accurate. I'm assuming either this value is off or the ground plane isn't having a proper margin set.