# [SOLVED] Keep the position from a RotateAround() around a moving object?

Greetings,
I am trying to find out a way to be able to store the position from the object after a RotateAround has happened. I have looked here:

However, anything I have tried so far has been unsuccessful, and I have looked a lot on the internet for solutions but it seems I am either bad at expressing myself or it’s not a common thing to do, or it’s just that it needs a different solution/approach.

1 Like

If you apply the example to the object which is rotates around the other object, then after moving the other object, the rotation recovers.
If you want to move them together, you have two options:

• make the rotating object child of the other object, this case the move together is automatic
• then you move the other object, you move the rotating object as well with the same translation (calculate the vector from the original position to the new position and apply it to the rotating object)

Parenting is not an option here, I need the child to be separate.

I have looked into this some more and it looks like the InverseTransformPoint() is something that could be used for this, but I tried and it didn’t seem to work…

Basically what I am after is a way to get the position of an orbiting object when it stops orbiting and keep the positional offset to the object it is orbiting around when it stops rotating. I have spent hours looking for something like this and have found a lot of near-solutions, but sadly nothing that can solve the situation.

What I have so far is this, which is based on the code from the above URL:

``````           float inputitude = RotationCurve.Evaluate(math.min(_inputs.sqrMagnitude, 1.0f));

float cameraEulerX = (CameraForm.eulerAngles.x > 180f ? CameraForm.eulerAngles.x - 360f : CameraForm.eulerAngles.x);

float xinput = (_inputs.x > 0f && cameraEulerX >= (RANGE_MAX - ERROR_MARGIN)) || (_inputs.x < 0f && cameraEulerX <= (RANGE_MIN + ERROR_MARGIN)) ? 0f : _inputs.x;

RotateAround(followPosition, _upOffset * _inputs.y + CameraForm.right * xinput, inputitude * _sensitivity * Time.smoothDeltaTime, distance);
``````

(This solves another issue that a lot of people seems to be having with clamping RotateAround, and this is without expensive calls to cross/normalisation.)

Nevermind, I made it work by saving the AngleAxis and direction when doing inputs and reassembling it into the correct positional offset.

Pseudocode:

if(doingstuff){
_angleAxis = currentAngleAxis;
_direction = currentDirection;
}

UwU