Hello everyone,
I’m in early stages of dev on a new project, and am currently stuck on moving the player object smoothly. I have a feeling something in my setup isn’t right. I’m on 2019.3 beta, using Physics 0.2.0, Entities 0.1.1, Burst 1.1.2.
My hacked together setup is:
-
Player entity with physics shape and body + gameplay components
-
Player-follow GO entity, used for MBs such as effects on the player
-
Camera follows the GO entity with some lerping
-
System to move GO entity to linked entity (which is the player entity)
-
System to move player entity based on input values
When moving the player via adjusting the Translate and Rotation components, it’s smooth as butter, however I believe this isn’t the correct way as it would require manually doing physics on the player each frame to ensure it doesn’t go through colliders, yeah?
When moving the player via the PhysicsVelocity ApplyLinearImpulse function, the smoothness is tied to the framerate, though even at a capped 60fps it jitters a little occasionally. On test device which fluctuates 40-50fps it looks terrible. I’ve tried moving the physics systems to fixedupdate, this made the player constantly stutter. I feel like fixed update + interpolation between frames could work.
I think my overall implementation isn’t correct. Feels like the physics is missing interpolation between frames.
Can someone please provide some guidance? This has been driving me crazy for a few weeks now. What is the correct way to move a physics body smoothly?