Jump to content
  • Advertisement
Sign in to follow this  

Integrating over arbitrary interval - with player/NPC inputs?

This topic is 2913 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

So ideally my physics engine should be able to perform a "tick" with any given time interval as the elapsed time since the last tick's end, and do all the collision etc that occurs during it.
My question is, how is an actor's input - whether from some AI script or a player's movement command, etc, dealt with? Basically, it adds a certain element to the simulation which could change at some point during that interval.

Example: Say my player moves to position (x2, y2) from (x1, y1). The way I had thought to be doing it is to apply a constant acceleration until the actor reaches (x2, y2) - allowing a negligible amount of movement beyond that point once the acceleration stops.. ground friction is very high.
But then for whatever interval which includes the actor moving past (x2, y2) - say the interval is large and the player reaches the destination point 1/2 through the interval - how is this handled? Do you just calculate the time at which input will change before-hand, and split it into two intervals? So you segment each simulation interval by every point at which any actor's input changes their acceleration vector?
This is the first solution that comes to my mind, but I haven't gotten to programming it and would appreciate feedback and any potential problems before I do. Are there other ways of going about it / thoughts?

Edit: One problem that comes to mind is that I'd essentially have to do some integration to find the time within the interval at which an actor's acceleration would need to stop (so the question of, "At what time during the interval do I reach (x2, y2)?" for the example above). With other objects and actors moving around, this could be nontrivial, right? Is my only option here to potentially overshoot destination points if intervals are relatively large?

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!