Look At with SmoothDamp

Hey guys, I want to use this “PlayerLookToMouse” script with a smoothDamp function, so it the player has a slight delay when rotating to the mouse.

Here’s the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LookToMouse : MonoBehaviour
{
public Camera aremac;
public LayerMask hitMask; // define this in the inspector! remember that checkmarks mean layers to hit
public float rayRange = float.MaxValue; // making this a public field is optional, but the value is needed for the Raycast call

void Start()
{
    //Cursor.lockState = CursorLockMode.Locked;
}

void FixedUpdate()
{
    RaycastHit hit;
    Ray ray = aremac.ScreenPointToRay(Input.mousePosition);

    if (Physics.Raycast(ray, out hit, rayRange, hitMask))
    {
        transform.LookAt(new Vector3(hit.point.x, transform.position.y, hit.point.z)); // Do something with the object that was hit by the raycast.
    }
}

}

You can save all desired values in a list. And invoke applying a value from this list a secound later. Instead of applying it to Camera.main rotation use it for your raycast
Here is an example:

List rotations = new List();

void SetRotation(Vector3 rotation)
{
rotations.Add(rotation);
Invoke(“Rotate”, 1);
}

void Rotate()
{
Camera.main.transform.eulerAngles = rotations[0];
rotations.RemoveAt(0);
}