- Home /
Move child objects in the opposite direction of parent object
My problem is as follows: I want my player to be able to rotate a platform and thus move a ball through gravity. The platform should always rotate around the x and z coordinates of the ball. For that I need to have a dynamic pivot point. I already know that Unity doesn't support the change of a pivot point neither through the editor nor by script.
My solution for the problem was to create a parent object to act as some sort of container whose x and z coordinates i would then set to be the same as the ball's. I would then have to counteract this change of position by changing the local coordinates of my child objects to the exact opposite of the parent object's.
The thing is: It doesn't really work. I also tried to translate the positions of my objects rather than setting them - that allowed me to change position of my parent object and thus the pivot point, but after some time it would just go flying and the child objects would behave very weirdly.
I have thought of two possible solutions that I don't really know how to implement:
Change the pivot point by changing the coordinates of the parent object. Works more or less, but not completely.
Add some kind of offset to the rotation. For the rotation I convert Euler angles to a Quaternion and I make use of the RotateTowards()-method so that it look a bit smoother.
These would be my thoughts on the problem. I have yet to try the latter idea (if it is even possible in Unity).
If you need any more information on the matter please feel free to reach out and ask any question that crosses your mind.
Thanks in advance.