- Home /
Is it possible to save a transform.position in a single variable?
So, I was wondering if there was a way (using jscript) to store a game objects transform.position within 1 static variable. Right now, I've been using 3 separate variables for the x, y, and z components of the objects transform.position.
posXBrick = gameObject.transform.position.x;
posYBrick = gameObject.transform.position.y;
posZBrick = gameObject.transform.position.z;
I was just hoping that someone knew a way that I could store it and call it without using three separate variables, to help keep the script cleaner.
Thanks
-Wylie
Answer by skovacs1 · Nov 22, 2010 at 09:37 PM
Have you tried something like var pos : Vector3 = transform.position;
?
transform.rotation is a quaternion -- use var rot : Quaternion = transform.rotation;
Yes, it's a Quaternion. You'd do something like 'var rot : Quaternion = transform.rotation;'. For most cases, people use stuff like transform.eulerAngles which is a Vector3 like 'var eulers : Vector3 = transform.eulerAngles;'.