Jump Mechanic ideas with Havok

Hello !
First of all, good luck for 7.0 !

My question is the following : I am developping a 3d game that is (will be) quite dynamic (lots of fast-paced and precise movement). I am using the Havok engine. The problem I have is with the jump mechanic. I deal with the movement by applying a LinearVelocity vector in the direction the camera is looking at when a key is pressed. if it’s “z” (“q” for english keyboard) the direction is the same as the camera, and if i want to go left right or backwards I apply a vector that is rotated accordingly, but still based off of the camera direction vector. This makes it so that the player constantly follows the camera’s direction, a bit like a FPS’s movement (except that the camera is behind the player). The problem is that I’m checking for button presses every tick, and therefore the LinearVelocity is applied every tick. My problem is that I can’t find a way of applying a vertical force/impulse with applyForce or applyImpulse that simulates a jump, without it being completely overwritten in the next tick by the LinearVelocity vector. I know that I’m probably doing something wrong, but I can’t figure out what exactly…
Would anyone have an idea on how I should deal with this issue ?

Thank you so much in advance !

And once again thanks for the framework, I love it !

1 Like

Hi @Eneim1 and welcome to the forum!
I like using set linearvelocity because of the controls it allows. This also means you’ll have to decompose things a bit more and not rely on existing things sometimes.
Many things are possible for a jump:

  • a complex solution is to have more state that computes the velocity of a jump from the time
  • another is to apply an impulse but then, when you handle linearvelocity, you don’t only set it. You retrieve the current linear velocity, change it (add damping, add jump velocity, lift,…) and then set it up.
2 Likes

Thanks a lot ! I will try this asap

1 Like