Some CharacterProxy Questions

Some CharacterProxy Questions

I want to use CharacterProxy & CharacterContext to control characters in my game. And I have knownhow toinitialize the move speed of the character in the state machine.

But the characters in my game have some special skills, such as move slowly, or jump with faster horizontal speed and lower height.

I want to know how tochange the Move Speed of aCharacterProxy, andset the horizontal speed of Jump.

Thanks.

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

I can answer one of your questions, but the other I would like to know myself.

You can set the speed of your character by simply changing the value you supply to hkpCharacterInput::m_inputLR and hkpCharacterInput::m_inputUD. A higher value for the m_inputUD will increase the speed of movement going in the forward direction. A lower ( such as negative ) will increase the speed going in the backward direction. Same applies to m_inputLR.

For instance, my movement code is based on a variable m_posX nad m_posZ in my class. And with those, if W is pressed I set m_posZ to an m_speed variable, and if S is pressed I set it to m_speed * -1.0f.

Hope that helps. I also hope someone offers an answer to the second one, as that'd be useful.

I'm afraid that all that happens when you jump is that an impulse is applied to the character rigid body. This can't be changed because it's done in the Havok source-code. However, with this in mind, there's nothing stopping you applying your own impulses and forces on the rigid body to make it move however you want it to.

Daniel

Moving a character in a non-physically correct way is an interesting problem. A lot of games do that (mine will too).
The thing is, that forcing a physics engine to do non-physically correct movement will probably be much harder than just moving the body kinematically. My approach will be to just animate the jumps, and use a hkpRigidBody::setLinearVelocity() each frame to move my character as I please. Maybe even better would be to use hkpCharacterProxy::setLinearVelocity() (not sure though - having hkpCharacterProxy source code would be very helpful here!).
There's also a probability, that in you game you would like non-physical collision response. In that case you would also have to listen to collisions (either on a phantom, or using hkpCharacterProxy::addCharacterProxyListener()) and either apply impulses directly and let Havok do the job (again - might be not what you want), or use keyframed animation with setLinearVelocity() again.
One thing that bothers me is that if I were to use a raw hkpRigidBody with a hkpShapePhantom shape, instead of a hkpCharacterProxy, I would miss on that magical "simplex solver" I know nothing about ;)

Regarding keyframing rigid bodies, have a look in:

PhysicsUtilitiesConstraintKeyframehkpKeyFrameUtility.h

applySoftKeyFrame() and applyHardKeyFrame() so setLinearVelocity() for you. Makes the calculations a little easier.

Daniel

Leave a Comment

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