Moving a physics object smoothly

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?

Unity physics have a physics and rendering world, so you perform your physics in the physical world, but render interpolated in the other world.

Hi hippocoder

Is there an example on the repo I can dive into? I have no clue how to render interpolated… for reference the entity has rendermesh on it. Am I missing some setting somewhere or do I need a new system?

Edit. If it matters, using the UniversalRP

I am interested in how to do this as well

I put this on the backburner and went onto other things. I figure once Physics and ECS are more mature there will be more info.

When I have things working nicely I will update this thread… in the meantime if anyone has a checklist sort of thing for moving something with the new systems using physics, please post it

I posted a question in the physics thread as well. We’ll see if an answer will be provided. If I remember correctly there were some mention that for the moment the system is fps depended but will be made independent in future releases.

This is the thread I was referring to: physics ApplyImpulse in editor vs release

Don’t know if anything changed since August thought…