To prevent the issue with lerp going to the shortest path, you need to use a rotation that is a sum of current rotation and some euler rotation.

The thing is, when you set target rotation as `Quaternion.Euler(0, 90f, 0)`

this quaternion represents a rotation that doesn’t take into account anything else and basically if you imagine it as a vector than it would be a direction vector `Vector3.right`

( `0, 1, 0`

). It doesn’t care about from which position it has been rotated, it just knows that it should point 90 degrees to the right from wherever, and the `(S)Lerp`

will simply try to rotate the transform to the `Vector.right`

direction and that’s it, and it will use the shortest path to do so. That’s how `(S)Lerp`

work.

So, what to do?

To create a rotation quaternion that will represent a continuing rotation from current to target with the given direction (is it `90 degrees around Y clockwise`

or `-45 degrees around Y counterclockwise`

?) you need to add this desired euler rotation to the current rotation of the transform, so the final target rotation will be `current rotation + 90f degrees around Y clockwise`

, as an example. Quaternions addition is made with `*`

, so to get the desired final rotation you do this:

```
Quaternion rotate90DegreesClockwise = transform.rotation * Quaternion.Euler(0, 90f, 0);
```

With this method, even if you set the euler rotation to, say, 250 degrees to the right, it will rotate to the right and won’t cut the path through the left side. At least I believe it should work like this, I use this technique with adding eulers to the current rotation in my camera rig setups, and it works fine with fast camera rotations:

```
transform.rotation = transform.rotation * Quaternion.Euler(0, 250f, 0);
```

Obviously, there’s a tricky nuance: you can’t just tell `rotate to the Vector3.right`

. Instead you will need to precalculate and prepare the euler quaternion so it would represent a rotation `some amount of degrees between current Y euler angle and target Y euler angle`

.

The actual method of preparing of the angle value would depend on your setup: do you use mouse input values or maybe you set some desired angle manually… So, I can’t tell how exactly you should calculate the current-to-target angle value.

However, here’s a part of my camera rig setup. This is a part of the CameraRotator script that handles camera rotation based on mouse input, I have cut other stuff and only left the stuff useful for Y axis rotation here. The `Rotate()`

method takes `Input.GetAxisRaw("Mouse Y") * Sensivity;`

and performs a transform rotation for the given amount of degrees in the given direction (to the left when mouse input value is `< 0`

, to the right otherwise).

Try to attach it to some object and see how it works. Maybe you could use it.

```
public class CameraRotator : MonoBehaviour
{
Quaternion targetRotation;
float currentAngleDelta;
public bool smooth = true;
[Range (0.000001f, 0.1f)] public float smoothDelay = 0.00001f;
[Range (0.1f, 10f)] public float Sensitivity = 6f;
public static float SmoothDelay(float current, float target, float delay = 0.001f, float dt = Time.deltaTime)
{
return Mathf.Lerp(current, target, 1f - Mathf.Pow(delay, dt));
}
void Update()
{
Rotate(Input.GetAxisRaw("Mouse Y") * Sensitivity);
}
public void Rotate(float angle)
{
targetRotation = transform.rotation;
if (smooth)
{
currentAngleDelta = SmoothDelay(currentAngleDelta, angle, smoothDelay);
}
else
{
currentAngleDelta= angle;
}
targetRotation *= Quaternion.Euler(0f, currentAngleDelta, 0f);
transform.rotation = targetRotation;
}
```