Child as pivot's parent
Maybe it's a silly question, i'm new in Unity.
I'm struggling to find a solution to change my gameObject pivot. I'm working on a very simple racing game that allows the users to transform 'live' their main vehicle changing its speed and axis rotation.
I've tried to attach to my Parent few empty gameObjects, each representing a pivot point for the different vehicles, using in the script attached to the parent:
transform.Rotate(transform.GetChild(0).up, * axisH * steering);
Obviously doesn't work. The parent gameObject always rotates around his main pivot.
I have drawn a couple of rays just to see if transform.GetChild(0).up exists, and yes, the Ray shows that the 'up' component is there, in the position i want my parent to rotate around.
Is there any other way rather than have an empty parent with the gameObject as a child? Is really impossible to control from script pivot points?
Thanks a lot
Answer by elmaxo77 · Aug 07, 2017 at 09:41 PM
there was a typo in the code, sorry :)
transform.Rotate (transform.GetChild(0) * axisH * steering));
Your answer
Follow this Question
Related Questions
Convert 2d object in 3d 1 Answer
I'm having a few issues with (Catmull)Splines that i need help with. 1 Answer
Object Jump 0 Answers
How can I add a shader to an entire environment? 0 Answers
Character move speed not working 1 Answer