Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ball which is being thrown from one side of a 2D space to the other. The formula I am using for calculating the ball's position at any one point in time is:

x = x0 + vx0*t
y = y0 + vy0*t - 0.5*g*t*t

where g is gravity, t is time, x0 is the initial x position, vx0 is the initial x velocity.

What I would like to do is change the speed of this ball, without changing how far it travels. Let's say the ball starts in the lower left corner, moves upwards and rightwards in an arc, and finishes in the lower right corner, and this takes 5s. What I would like to do is change it so the ball still follows the same curve and finishes in the same position, but takes 10s or 20s to do so.

How can I achieve this? All I can think of is manipulating t but I don't think that's a good idea. I'm sure it's something simple, but my maths are pretty shaky.

share|improve this question
up vote 7 down vote accepted

Actually, you're correct -- without switching equations, the only way you have of altering speed without altering the path is to manipulate t.

For the given x0 and y0, you need to record t0. Then:

rate = 0.25 // run path at one-quarter speed

t' = (t - t0) * rate

x = x0 + vx0*t'
y = y0 + vy0*t' - 0.5*g*t'*t'

Essentially what you are doing is slowing down time for the ball's path, without slowing down anything else.

share|improve this answer
Hmmm, ok - so now the tricky part. Say I have 10 balls, and vx0 and vy0 are randomly selected for each ball (within certain constraints). What I want to do is have all the balls moving at roughly the same speed. How do I determine rate based on vx0 and vy0? Or should I be looking at a different set of equations? – Ben Williams Feb 1 '11 at 2:35
You won't ever get them all moving at the same speed -- indeed, the function for y ensures, via 0.5*g*t'*t', that all balls are constantly accelerating toward the ground. If all you want to do is to match apparent starting velocities, while, say, allowing some balls to travel higher, you need to modulate rate based on the magnitude of (vx0, vy0); in other words, sqrt(vx0*vx0 + vy0*vy0) * rate = <desired global speed>. – Blair Holloway Feb 1 '11 at 3:33
Perfect. Thank you. – Ben Williams Feb 22 '11 at 2:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.