# Basic Kinematics confusion

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

## Recommended Posts

I tried to write a program to test my knowledge of kinematics. It does what I wanted it to do (somewhat), but the way it's implemented makes me wonder if I have the idea of kinematics down. What I was trying to do was have a single particle simulate the water of fountain. It has a initial velocity, it goes up for a while, then comes down due to gravity. I used the formula x = v0xt + (axt^2)/2 y = v0yt + (ayt^2)/2 I was under the impression that x and y in formula was "displacement" and I could "+=" (C++) the value to my game object's position. Doing this resulted int the particle shooting off the screen. If I just use "=", then I get the correct results, but that means my object can't have a initial position. I would post some code, but I'm at work at the moment.

##### Share on other sites
That formula describes the current position at t given an initial position, initial velocity, constant acceleration. It's full form is:

x = x0 + v0_x * t + (a_x * t^2) / 2.

And similarly for y.

So there are two ways for you to solve this:

1. Remember the intial position (x0), then add those values to the position every frame, as described in the function. This, however, does not allow for any sudden changes in velocity or acceleration as you're essentially recalculating the entire path every frame.

2. Update the position (as you first tried), but use:
x += v.x * dt
v.x += a.x * dt
where dt is the change in time since the previous update. Probably the best solution in the general case. Acceleration and velocity can now change as often as you'd like.

##### Share on other sites
Accidental double post. The other, more recent at the time of this action, thread is here.

##### Share on other sites

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

This topic is now closed to further replies.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 27
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634100
• Total Posts
3015527
×

## Important Information

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!