This project has moved. For the latest updates, please go here.

# How do you increase the velocity of a vector

 Topics: Developer Forum, User Forum Wiki Link: [discussion:226017]
 RogerGuess Sep 3, 2010 at 9:25 PM Say I have a Vector2 for a Body. How can I over time continually (every loop) add to it's velocity?   Thanks, genbox Coordinator Sep 4, 2010 at 1:33 PM A vector is made up of 2 things: A length (magnitude) and a direction. If you multiply a scalar (single value; a number) with the vector, you will increase (if the scalar is >1) the magnitude of the vector. Example: Vector2 force = new Vector2(10,0); // 10 in force along the x-axis force = force * 2; // 20 in force along the x-axis To apply a constant force, you use the Body.ApplyForce() method. Give it the force vector as an argument. crashlander Coordinator Sep 5, 2010 at 7:31 PM Yes, as genbox says. Apply a force every loop in the direction you want to go. RogerGuess Sep 5, 2010 at 8:02 PM ﻿ I am missing something (as you can see, I am using Andy's helper)...                 //missiles                 foreach (PhysicsSprite missile in missiles.Values)                 {                     Vector2 vector2 = missile.BodyObject.Force;                     vector2 = vector2 * 2;                     missile.BodyObject.ApplyForce(vector2);                     } However, it does not seem to 'accelerate'. Pnikosis Sep 6, 2010 at 6:32 AM Edited Sep 6, 2010 at 9:00 AM If you want to duplicate the body's velocity, you should use impulse instead:   ` //missiles foreach (PhysicsSprite missile in missiles.Values) { Vector2 vector2 = missile.BodyObject.LinearVelocity; vector2 = vector2 * 2; missile.BodyObject.ApplyLinearImpulse(vector2); }` Edit: Sorry, this should triplicate the velocity, for duplicating it, dont multiply "vector2" by 2. RogerGuess Sep 6, 2010 at 4:50 PM Edited Sep 6, 2010 at 4:50 PM Now I'm in business: `                //missiles                foreach (PhysicsSprite missile in missiles.Values)                {                    Vector2 vector2 = missile.BodyObject.LinearVelocity;                    if (vector2.Length() < 2000)                    {                        vector2 = vector2 * .02f;                        missile.BodyObject.ApplyImpulse(vector2);                        }                }` Thanks all!  ﻿