Character Controller Vibration Issue in Havok Physics

I’m using Havok Physics for my character controller, but I’m encountering a shivering or vibrating effect when my character moves or jumps, as shown in the video. Despite checking my setup, I can’t pinpoint the cause of the issue. Below is the code snippet showing my physics setup and how I trigger the jump. Currently using the latest packages. Any suggestions or insights would be greatly appreciated!

;; Havok init
(let [hk (HavokPlugin. true hk)
      gravity (v3 0 -9.8 0)]
    (j/call scene :enablePhysics gravity hk)

;; Character physics aggregator
(api.physics/physics-agg {:mesh player-capsule
                          :type :PhysicsShapeType/CAPSULE
                          :mass mass
                          :restitution 0
                          :friction 0
                          :linear-damping 2.2
                          :angular-damping 2.2
                          :gravity-factor 2
                          :motion-type :PhysicsMotionType/DYNAMIC
                          :mass-props {:inertia (v3)
                                       :mass mass}})

;; How jump gets triggered
(let [player-pos (api.core/get-pos player-capsule)
	  jump-vec (v3 0 1500 0)]
   (api.physics/apply-impulse player-capsule jump-vec player-pos))

Could you try setting the linear velocity instead of applying an impulse to see if that reduces the vibration?

I’m also using only setLinearVelocity for normal movement (WASD) which has the same vibration issue as you can see in the video.

1 Like

Can you repro in a PG?
It’s hard to find the cause without otherwise.
My first guess is the order of updates between physics and scene transforms. If there is 1 frame delay between some updates then vibration/lag can appear.
Again, hard to say without a repro. Do you use physics debug display?

Yes this triangles coming from physics debug display. I’ll try to create a PG, since I’m using another language I could not create a PG at first. Will let you know.

1 Like

The weird thing is when I change first paremeter of HavokPlugin true to false I don’t see the vibration. (HavokPlugin. false hk) but I’m not sure that is right way, because now everything is changed; speed of the chracter, jump height etc.

1 Like

with variable delta time, it’s possible distance done by the character between 2 frames is non consistent. With fixed timestep, distance will be the same.
maybe it’s a screen and refresh rate + delta time issue.
anyways, best is to repro in a PG :slight_smile:

2 Likes

@Cedric It turns out the issue was on my end. I had an invisible box at the center of the screen to simulate a target offset for my TPS setup camera.setTarget(boxInTheMiddle). The problem was that the box was under the root node, not my character. After I moved the box under my character and updated its local position relative to the character, instead of adjusting its global position, the shivering issue was resolved. It seems odd to me that this caused the problem—did I miss something here?

3 Likes

If there is collision/response every frame plus setting position of the body then it seems like a reasonable behavior.

1 Like