Hello, can you please help me with vectors?

I need to translate a Vector without using a transform.

Now I simply set the Position to a ‘dummy’ game object and then use the Translate function of its transform (this way I can find the new Position of the translated vector).

Is there an alternative way that can help me avoid using a gameObject’s transform?

Thanks!

Simone

Hmm, this should work:

```
yourObject.transform.position += Vector3(10, 2, 40);
```

Thanks, I’ll test it later

Most vector math is really easy.

To translate a vector by another vector, just add them together.

To find the distance between two vectors (as a vector), just subtract one from the other. To convert that distance vector to a float, just take its magnitude.

To get a vector that points to another vector (let’s call it X), subtract the first vector from X.

To scale a vector just multiply it by a scalar (float) value.

To rotate a vector… it gets complicated. :lol:

I have a doubt about translation: how can I tell a vector to translate 3 units to the right?

Depends. If you mean the object’s local right, do this: transform.position = transform.position + transform.right * 3;

If you mean the world’s right, then do this:

transform.position = transform.position + Vector3.right * 3;

Hi

I found the article on Vector math in the very first issue of Unity Developer Magazine extremely helpfull and informative

http://www.unitydeveloper.com/

it explains the basics

BTW: I love the mag, its well worth the money