# Translate using a magnitude and angle direction

Hi,

I want to know if there is a way to translate an object using a vector, I mean, using a magnitude and an angle direction; not x,y,z coordinates.
I want it to make a pong game, so the ball movement is creating me trouble since I use normal Vector3 objects to move it.

Thank you.

Just normalize your direction vector and multiply it with the magnitude.

``````Vector3 v = myDirVector;
v.Normalize();
v *= magnitude;
transform.Translate(v);
``````

Set one component to the magnitude times the sine of the angle, and another to the magnitude times the cosine of the angle. Which components you choose will affect which plane (XY, XZ, YZ) the ball moves in, and also which direction is considered “zero”. You can also make either or both of the values negative to change the zero direction and whether angle increases clockwise or anticlockwise.

So try:

``````magnitude * new Vector3(Mathf.Deg2Rad * Mathf.Sin(angle), Mathf.Deg2Rad * Mathf.Cos(angle), 0.0f)
``````

This moves the ball in the X-Y plane, with zero being straight up (positive Y), and 90 degrees being to the right (positive X).

gfoot, your solution does not work properly, the translation is not following the correct angle I set.