- Home /
Find GameObject Position(x,z) and rotation(y)
How do I can locate the position and rotation of an object in constant motion?
I am creating a car neon lights, for better performance!
Take a look at these :
http://docs.unity3d.com/ScriptReference/Transform-position.html
http://docs.unity3d.com/ScriptReference/Transform-eulerAngles.html
And if you need to find an object to use these with :
http://docs.unity3d.com/ScriptReference/GameObject.Find.html
If this is not what you need then maybe put a little bit more info in your post, "I am creating a car neon lights, for better performance!" is pretty vague... :D
Answer by M-G-Production · Dec 04, 2014 at 05:10 AM
Hi gonzalo rivero!
theCar.transform.position will give you a Vector3 variable (Vector3 are 3 floats stored in a single var. Ex (x,y,z)) theCar.transform.eulerAngles will give you another Vector3 variable.
I would put this in the update function of your neon lights script.
Don't forget to make some Maths! Because if you say something like:
neonLight.transform.position = theCar.transform.position;
neonLight.transform.eulerAngles = theCar.transform.eulerAngles;
It will simply follow the car from its Origin...
If you need more tips, please consider showing me more infos in your question!
Bests Math
Your answer
Follow this Question
Related Questions
How to check if an object is upside-down? 2 Answers
transform.Translate moving while upside down? 1 Answer
How can I defer the recalculation of child transforms whilst modifying the parent transform? 0 Answers
why update function doesn't work on the transform.Rotate function 0 Answers
Align objects based on child objects 0 Answers