I have two objects: Pistol and Bullet. Bullet is the child of Pistol. If I try to rotate bullet (in code) it’s also rotating pistol. Any ideas?,I have two objects: Pistol and Bullet. Bullet is the child of Pistol, but if I try to rotate Bullet the pistol is also rotating. Any ideas?
Code:
GameObject.Find("M1911").transform.Rotate(0, -90, 30);
Hierarchy: https://i.imgur.com/UQsg12g.png
Assuming that there is only 1 bullet.
GameObject.Find(“M1911”).transform.GetChild(0).transform.Rotate(0, -90, 30);
To make the rotation truly independent from the parent, use localRotation.
edit.
I just noticed your picture, I saw that bullet is not a child of M1911, but instead is the child of Character.
You can use, GameObject.Find(“Bullet”).transform.localRotation(0, -90, 30).