I simply want a game object to orbit a fixed point on a plane. Imagine a standard model from school of the earth orbiting the sun.
What makes it complicated is that I also want my game object to still react to other objects, for example if it is hit from the front by a bouncy object it should change direction while still keeping its distance to the center point.
Before Unity, I build the exact same thing with Box2D (different Physics engine). I simply fixed a joint to the center point and the game object. Done.
In Unity, it does not seem to be that easy. The moment my game Object gets fast or is hit by another object, the joint will not stay in place. It will wiggle and the circular motion might even become more of a rectangle if movement is fast.
I tried a hinge joint with the hinge on top of the center Point and also linking a central object to the circling one via fixed joints and a long object in between.
I have learned that the problem can be helped by
a) lowering the minimum time step
b) raising the iteration count
I tried both options and they wont do for me, since keeping the distance in that case is really central to my game and
a) both options still won’t fix the problem completely
b) I am afraid that I will regain rectangular motion when fps drop, as the time step will then go up.
What I am now planning to do is to use Transform.RotateAround, thereby orbiting by hand. This means that i will have to handle any physics related Behavior myself, since Transform.RotateAround is not part of the physics engine, which means it does not cause any real movement.
So I would like to know:
Is there any other way to orbit a position? Or maybe even a way to make a joint stay in place, therefore reliably keeping a distance between an object an a point in space?