I am new to C#. I was wondering if anyone would be so kind as to explain to me exactly what a Vector1, Vector2, and Vector3 array(s) are? I see them often in sample scripts, though I do not clearly understand their meaning. I cannot find a clear definition of what these things are anywhere so far.
I read Microsoft DOCS concerning C# - to no avail. Can anyone please assist me in understanding what Vector1, Vector2, and Vector 3 is? And why/where you would use them? I am asking for an explanation in understanding how to use these things in a practical sense. I thank you for your time - Jah bless.
First, there isn’t a Vector1 type in unity, technically if you wanted one it would just be a named float type variable.
Vector2 has a bunch of helper methods for basic Vector2, the same goes for Vector3 and Vector4.
Each vector is a struct, a struct is a value type, when you for instance: create a VectorN(where ‘N’ is 2, 3 or 4) from another VectorN, you are creating a copy of the original VectorN, and it’s fields(Vector2 has x and y, Vector3 has x, y and z and Vector4 has x, y, z and w).
If you create an object based off a class opposed to a struct, when you instantiate the object based off another object, that object only copies the reference to the original object you’re trying to “copy”, this reference points to the same values in each object in memory.
If you change one, you change the other, however there are caveats to this.
In Unity 3d mode, GameObjects positions are Vector3, or X/Y/Z, where x is typically the horizontal, Y is the vertical and Z is going through he screen. For a Vector2 which could be used for mouse position(X and Y) or in Unity in 2D mode, the X(horizonal) and the Y(vertical) for GameObjects positions makes complete sense right?
Vector4 is a little more specialized(shaders and such, but Vector3 and 2 are also used), though you can use the Vector structs anyway you desire
@Landern see this is so interesting: 1 I need an opinion of what kind of vector is Vector xp; and Vector y , yd; because in the method : SecondOrderDynamics “y” take the value 0.