#Make player movement frame independent

7 messages · Page 1 of 1 (latest)

devout marsh
somber fractal
#

I'm presuming that the delta parameter to useFrame() is a time elapsed since previous frame; if so, then you need to move the player by an amount proportional to delta. (Essentially, by speed * delta, in the right units).

devout marsh
#

well that works if i am setting the position

#

as i am already setting the linear velocity over here i dont think i should use delta ... even when i tried multiplying current speed with delta it didnt work 😦

somber fractal
#

Ahhh, I missed that; mea culpa.

#

Is this line correct? It reads a little fishy...

playerRef.current.setLinvel({ x: direction.x, y: velocity.y, z: direction.z })
#

Oh wait, it's a y-up world and you're getting the y component of movement from the jump, not the player direction?