How can I get the coordinates for each of the object’s three vectors?
(we can assume each has a length of 1 if necessary)
(Preferably global coordinates or relative to parent)
(blue, green, red) vectors
How can I get the coordinates for each of the object’s three vectors?
(we can assume each has a length of 1 if necessary)
(Preferably global coordinates or relative to parent)
(blue, green, red) vectors
The blue, red and green vectors are not really coordinates, but represent the internal x, y and z axes, their local values usually are (1, 0, 0) and (0, 1, 0) and (0, 0, 1) when normalized (“length” = one) – or (x, y, z).
Accessing them separately is useful, which is why they can also be referred to (and are normalzed) as transform.forward (z axis), transform.up (y axis), transform.right (x axis).
If you access up, right, forward, you’ll get the normalized WORLD representation of the colored vectors (which makes sense, as in local space they are simply the unit vectors mentiones above)
How can I get the global coordinates of say transform.forward if it’s length would be 1? I could manually put an object and move it a distance of 1 on that axis and then look at it’s global position but perhaps there’s an easier way?
I recommend you refresh your memory on vector math - it’s not overly complex, Once you have re-acquainted yourself with the fundamentals I’m sure you can answer above question yourself, or rephrase it in a way that makes sense. You seem to be mixing up Points (which have a location but no direction) and Vectors (which have a direction but no location). Alternatively, try to describe the problem you are trying to solve, and we can go from there,
The position property of your Transform component gives you everything that you need.
transform.forward and the like give you the unit direction in your local space, so doing something like: transform.position += transform.forward * 5.0f;
will move your object 5 units along its z-axis. transform.up returns the y-axis, transform.right returns the x-axis.
The transform.position is the coordinates of your object and you can access each one individually using transform.position.x, transform.position.y or transform.position.z - that will give you each “coordinate” value in world space. If you want to get your local space coordinates you can use transform.localPosition.