Advertisement Jump to content
Sign in to follow this  

When to apply physics update in game?

This topic is 1091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using Farseer Physics in XNA, using C#. The physics engine updates through a step function with a time value as a parameter. Currently I have the step happening at the beginning of the frame, but I just realized that, if I press a button for the player to move, the physics engine doesn't know about it until the next frame, and I am drawn stationary the first frame a button is pressed. This has led me to believe that placing the physics update last every frame will solve all my problems, but I now have an additional worry. There are some occasions when I want to respond to a collision with an instantaneous velocity change. My code listens for a collision, and then responds to it by adding an additional velocity to one of the colliding objects. The problem with this is that the velocity change isn't seen by the physics engine until the next engine update.


I am trying to create a gravity lift that directs an object's velocity a certain direction at a certain magnitude in response to a collision, and I need the change to be immediate. I can't really figure out a way to do it, short of altering the code of the physics engine itself.

Share this post

Link to post
Share on other sites

Can you apply user input before the physics update, and respond to physics events after?

inputs = GetInputs()
events, worldState = UpdatePhysics(inputs)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!