I am not sure if the name of the question is sufficient.

My question is this:

I have a code that lets a camera rotate around an object (the player's name is "hero").

```
Quaternion nNewRotation = Quaternion.Euler (_CameraDefaultPos.y, _Orbit_CurrentYaw, 0);
Vector3 vCurHero = new Vector3 (_HeroPos.x, _HeroPos.y, _HeroPos.z);
Vector3 negDistance = new Vector3 (_CameraDefaultPos.x, fUpDownPosition, _CameraDefaultPos.z); // fUpDownPosition was previously calculated from "Mouse Y"
Vector3 nNewPosition = nNewRotation * negDistance + vCurHero;
Vector3 nNewRotationVector = new Vector3 (_Orbit_CurrentPitch, nNewewotation.eulerAngles.y, nNewewotation.eulerAngles.z);
nNewRotation = Quaternion.Euler (nNewewotationVector);
_camera.transform.localRotation = nNewewotation;
_camera.transform.localPosition = nNewPosition;
```

This code works fine.

Now there is a situation where the hero changes from target to orbit.

While aiming, the camera enlarged the model. This means that the camera's local z position was -0.6f instead of -0.8f ("_CameraDefaultPos.z"), for example.

When transitioning from target to orbit, the camera's local Z position is smoothly returned to the default Z position.

I tried to include the fact that the camera may only change its z position, but all my attempts resulted in an unwanted camera position.

The next time I could get something:

```
Vector3 vCurHero = new Vector3 (_HeroPos.x, _HeroPos.y, _HeroPos.z + (_CameraDefaultPos.z - _camera.transform.localPosition.z));
Vector3 negDistance = new Vector3 (_CameraDefaultPos.x, fUpDownPosition, _CameraDefaultPos.z);
```

But the camera is really shaky.

Does anyone know where my calculation is wrong?

Many Thanks!