- Home /
instantiating prefab does not rotate child objects correctly?
When I instantiate a prefab and move it with script the child object does not rotate correctly, it is slightly off. But when I instantiate a prefab and use the inspector to move the object at run time the child object does rotate correctly.
Any ideas?
You're probably not going to get much help unless you show us the code in question.
Answer by spilat12 · May 20, 2018 at 08:28 PM
I had a similar situation once. When you change transform values in the Inspector manually, it is transformed in local space. Most likely, in your script you are rotating your object in the world space, hence the difference.
Note that Transform component has Transform.rotation to store objects' rotation in world space, while local rotation is represented by Transform.localRotation.
Same goes for position and scale - their local space counterparts are localPosition and (you guessed it!) localScale! I hope this helps, but feel free to include your script!