- Home /
Question by
maxisbestest · Jan 15, 2019 at 02:23 PM ·
rotationparentchild
how do I get Parent rotation on Child,how do I use a parents rotation in a child?
I have my Camera as a child of my Player and I want to link the rotation of the Camera based on the Player, but I don't know how to get the parent rotation in the child code.,I have my Camera as a child of my Player and I want to in the Camera code link its rotation to the Player.
Comment
Answer by xxmariofer · Jan 15, 2019 at 02:30 PM
To access the parent from the child you can use transform.rotation = transform.parent.rotation.
Answer by badadam · Jan 15, 2019 at 06:39 PM
You can use this command.
transform.parent.gameObject.transform.rotation
thats going to give nullreference exception cause you are trying to access the transform from a transform.
I fixed it. You can click to up vote.
transform.parent.gameObject.transform.rotation;
yes that works but no need of the gameObject.transform.