Is it possible to make a child object rotate independently of the parents rotation and keep the parents position?
In my scene the parent/player, with a rigidbody on it, has a mouselook script that allows me to see wherever I point the mouse. When the player hits a “gift box” a spinning wheel, that is actually a child object, is enabled/activated and starts rotating on the Y-axis using add force and it’s own rigidbody.
But when I look around while the wheel spins, it gets all messed up and spins in every-which direction. No constrains have worked to solve the problem. I have found 0 solutions in the forums. HEELP!!!
I can’t simply instantiate the wheel and not have it as a child object, because it is part of a much larger coordinated set of functions and objects that are instantiated when the level is loaded (multiplayer game). But there must be a solution to this frustrating issue. I would greatly appreciate the help.
It’s such a small thing: Make a 3D object wheel spin and stay in front of the camera as though it was a GUI, and stay in place regardless of the mouselook script…Can anybody help me fix this?
If you can’t have your wheel out of player hierarchy, then you need to compensate parent’s rotation. In late update, after all animations and effects and controls applied, set the wheel global rotation to desired value to override parent rotation:
Thank you so much for your reply. I tried applying the code to the camera that has the mouselook script on it and then add public GameObject wheel; But it seems to override the rotation force on the wheel and turn it on it’s side. I tried Mathf.Sin(Mathf.Deg2Rad * Time.time on all axis and it didn’t work, but I’m sure the counteracting principle is the key.