How To Smoothly Rotate The Object? Pls Help!

I want to smoothly rotate the player when clicking LMB using this code

void Update()
{
if (Input.GetMouseButtonDown(0))
        {
            if (transform.rotation == Quaternion.identity) //if LMB and current Y degree equal to zero i move it to 90 degrees to left
            {
                transform.rotation *= Quaternion.AngleAxis(-90, Vector3.up);
            }
            else //if LMB and current Y degree equal to -90 (player moves left) i move it to 90 degrees to right (back to 0 world degree)
            {
                transform.rotation *= Quaternion.AngleAxis(90, Vector3.up);
            }
        }
transform.Translate(Vector3.forward * speed * Time.deltaTime); //running forward
}

If the rotation is smooth, it will take a lot longer - won’r your game break (the tiles behind start dropping fast) if the player takes more time to turn?
In any way, instead of turning your char by 90 degrees immediately, start a turn by setting a ‘turning’ and ‘targetRotation’ and then simply lerp. But again, this will take time and might brak your gameplay.

Cheers,
-ch

Tiles start falling after 1 second after player exits tile trigger collider. Can u help with code? I tried different variants such as:
Quaternion moveLeft = Quaternion.Euler(0, -90f, 0);
transform.rotation = Quaternion.Slerp(transform.rotation, moveLeft, .5f);
and
Quaternion.RotateTowads()
and it doesnt work

You could set a target rotation and lerp to it.

    private bool _isForward = true;

    private Quaternion _targetRot = Quaternion.identity;

    [SerializeField]
    private float _rotateSpeed = 5f;

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            _isForward = !_isForward;

            _targetRot *= Quaternion.AngleAxis(_isForward ? -90 : 90, Vector3.up);
        }

        transform.Translate(Vector3.forward * speed * Time.deltaTime); //running forward
        transform.rotation = Quaternion.Lerp(transform.rotation, _targetRot, _rotateSpeed * Time.deltaTime);
    }

You will need to change how your movement is dealt with though.

Its beautiful, thx a lot!

This helped a lot! Thanks