how does havok make character jump?

how does havok make character jump?

Hi ,

I use the physical formula to simulate the jump of character.like this :
update(float fTime)
{
...
if(isKeyDown(KEY_SPACE))
{
forwordVelocity += vector3(0.0f , 6.29 ,0.0f) ; // take upward velocity into account when determining the desired velocity
startJumpos = pCharacter->getPos() ; //get current's position
jumpTime = fTime ;
}
...
if(isInAir)
{
t = fTime - jumpTime ;
pos = startJumpPos + forwordVelocity* t + 0.5f * vector3(0.0f ,-16.0f ,0.0f) * t * t ;
if(IsBackOnGround(pos))
{
isInAir = false ;
}
pCharacter->setPos(pos) ;
}
....
}

butBut I found the character in thisway jumped farther than the one in the ControlCharacterRb demo.
someone can expland it ?

forgive my broken english .

Please help
thank you in adance.

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi coast,

If you are using the hkpCharacterRigidBody, then it is best not to set the position of the rigid body directly. This is a very costly operation since it causes an update to the broadphase. It is much better to calculate the velocity and set the velocity. This is so the physics system can handle the actual movement of the hkpCharacterRigidBody. You can take a look at the way the hkpCharacterStateJumping and the hkpCharacterStateInAir handle jumping.

We fully expect people to overwrite the way the character movement is handled for either the CharacterProxy or the CharacterRigidBody. These states are just a guideline for how to do states in general.

I hope this helps.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Quoting - sean.thurston

You can take a look at the way the hkpCharacterStateJumping and the hkpCharacterStateInAir handle jumping.

Sorry for the noobe question, but where may I find the code of hkpCharacterStateJumping or hkpCharacterStateInAir, I could only found their .h files.

Thanks

Yinon

Hi Yinon,

Sorry about that, where you can look is in the Animation/Api/Motion Extraction/CharacterController/StateMachine folder for how states can be written.

You should be able to create a jumping state that uses update to use your formula. One thing to note is that our jumping code uses a set jump height in its calculations, it happens to be 1.5 meters. So that is probably why yours jumps differently. Just remember that it is best to calculate for the velocity and not for the position.

Hopefully that helps,
Sean

Developer Support Engineer Havok www.havok.com

Leave a Comment

Please sign in to add a comment. Not a member? Join today