Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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'm trying to get this object to move right across the screen until it gets close to the center and arc down smoothly into a straight downward movement. Here's what I've tried:

if (position.X < -5000)
   Velocity = Vector3.Right * speed;
else if (position.X < -1000)
   Velocity = new Vector3(
   MathHelper.Lerp(Velocity.X, 0, (float)gameTime.ElapsedGameTime.TotalSeconds), 
   MathHelper.Lerp(Velocity.Y, -1, (float)gameTime.ElapsedGameTime.TotalSeconds), 0) 
   * speed;
   Velocity = Vector3.Down * speed;

However, when it gets to where it should be arcing, it just moves to the right at blinding speed and vanishes before it hits the point where it should be going straight down. If I remove the else if, it does a sharp direction shift no problem. What am I doing wrong in that section?

share|improve this question
up vote 2 down vote accepted

Your problem is (float)gameTime.ElapsedGameTime.TotalSeconds. Those Lerp functions you're using want a value that varies from 0 to 1, while TotalSeconds is going to keep increasing forever.

Maybe instead pass in the amount of time that has passed since the object started turning, and stop lerping after a time of 1?

share|improve this answer
gameTime.ElapsedGameTime.TotalSeconds is going to be the time since the last update. You're thinking of gameTime.TotalGameTime.TotalSeconds, which is the total from the start of the game. – Fibericon Mar 14 '12 at 3:17
Whoops! Either way, it's not the value that he actually wants to be passing into the Lerp. – Trevor Powell Mar 14 '12 at 4: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.