Jump to content
  • Advertisement
Sign in to follow this  
HalcyonX

Player control: position, velocity, or acceleration?

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

Im making a game that involves the player controlling a human character, and am faced with a problem im sure everyone has encountered. When the player hits the "up" key, the character is supposed to move forward. At first, I made it so that if the "up" key is held down, then at every cycle of the game loop, the character's position is moved forward by some amount. It worked fine until i tried to implement physics. For physics, i need velocity and acceleration. When a force is applied, acceleration changes. At every cycle, i update velocity based on acceleration, then update position based on velocity. This, then, is a problem, because the change in position due to the "up" key is not reflected in the velocity. I then thought about having the "up" key adjust velocity, but then that would cause a similar problem between velocity and acceleration. If i make it adjust acceleration, it would involve some weird logic. Anyone know of a good solution? What is the method used in most games? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
well, the idea is trully simple. but i advice to practice caution. it took me quite some time to get things work the way they should. what's more, i bet you're going to get some phisics and maths books soon to refresh your primary school knowledge. this happened to me ;-)

anyways, good luck with your porject.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!