How can I rotate a tank's turret back to the starting turret position?

I have a tank in my game and I’m trying to figure out how to rotate the turret back to the position it started after there are no enemies in sight.

public Quaternion TurretRest;


public void Start()
{

TurretRest = this.gameObject.transform.FindChild ("Turret").transform.localRotation;

//Should be  (0,0,0) when looking at the localrotation

}


    Quaternion Rot3 = Quaternion.LookRotation(TurretRest);
//Cannot use a quaternion (TurretRest) after the look rotation so what would I put there instead?
    
    
    				Turret.transform.rotation = Quaternion.Slerp (Turret.transform.rotation, Rot3, Time.deltaTime);

Just declare Quaternion myInitialRotation;

In Start assign gameObject.transform.rotation to it.

In update, when no enemies are visible, rotate towards this “cached” value

I think the problem is that TurretRest is set to the turret’s default local rotation,
but then you’re setting it’s world rotation to it’s local rotation.

Try replacing:

Turret.transform.rotation = Quaternion.Slerp (Turret.transform.rotation, Rot3, Time.deltaTime);

with:

Turret.transform.localRotation = Quaternion.Slerp (Turret.transform.localRotation, Rot3, Time.deltaTime);

and let me know if it works.