C# Coding Vector

So I think the commend I need to learn to move a object. An example would be moving an object at (y.1) to (y.3). I believe I need to learin what this Vector thing is, but by all means i’m no coder. So can someone explain a few things? Like 1.) What all does vector do? 2.) Quick ways of learning Vector (or if I mistaken something else for Vector, then whatever I mistaked it as tell me). Much apprecated if I can get new explanation because I am still confused.

Hi @MrPuppyy ,

I think it’s best to go check a few tutorials on vectors.
I just cut’n’pasted these from my notes to someone a few days ago, so here you go:

https://docs.unity3d.com/Manual/UnderstandingVectorArithmetic.html
https://wildbunny.co.uk/vector-maths-a-primer-for-games-programmers/
https://gamedevelopertips.com/vector-in-game-development/

Thanks! I will check into this here soon. But one more question, any way to quickly learn lot more commands I guess quickly? Or will I need to keep watching tutorials and stuff?

You will probably find a few tutorials on the basics if you just search for how to move objects in Unity. That’s best place to start. You don’t really need to understand vectors if you need to move your object to cardinal directions like “left” and “forward”.

Ok, I think I am understanding Vectors. Is there a difference between Vector, Vector1, Vector2, and Vector3?

Also, one more thing if you don’t mind. How do you change your speed in which it moves?

Vector2 can describe a 2-dimensional direction, and Vector3 a 3-dimensional… Just think it as an arrow pointing somewhere in space.

To change “speed”, you would probably want to multiply an unit length vector (length of one) with a speed variable and usually with Time.deltaTime so that you get the get object moving at steady pace.

moveDirectionVector.normalized * speed * Time.deltaTime;

They are literally just multiple numbers grouped together.

float is one number
Vector2 is two numbers
Vector3 is three numbers

int is one whole number
Vector2Int is two whole numbers
Vector3Int is three whole numbers

The difference is that the Vector2/Vector3 structs have useful related functions/properties you can use, such as Vector3.Normalize, Vector3.Reflect, Vector3.Distance, Vector3.forward, etc, that don’t make sense if there is only one number.

Okay. I believe I know what you mean. “MoveDirectionVector” Is where I want it to go? And also where do I put it in a script? I can show you what I got now.