Animation overrides Vector3.lerp

I have a gun sway and recoil script, but whenever I’m in an animation state (even an empty one) It overrides the lerp, and the sway and recoil just don’t work. This is pretty frustrating considering the only other person I found with this problem had it back in 2013, and no one answered, my code for the sway just to give you an idea:

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

public class Sway : MonoBehaviour {

    public float swayAmount;
    public float smoothingAmount;

    private Vector3 initialPosition;

    // Use this for initialization
    void Start () {
        initialPosition = transform.localPosition;
    }
   
    // Update is called once per frame
    void Update () {

        float mouseX = Input.GetAxis("Mouse X") * swayAmount;
        float mouseY = Input.GetAxis("Mouse Y") * swayAmount;

        Vector3 finalPosition = new Vector3(-mouseX, -mouseY, 0);
        transform.localPosition = Vector3.Lerp(transform.localPosition, finalPosition + initialPosition, Time.deltaTime * smoothingAmount);
    }
}

Use LateUpdate().

I tried that just now, it kind of works, but the movement created by the script is quite glitchy when I use LateUpdate

That’s a separate issue, it could be something with the way you’re applying the transform change but there’s nothing wrong with doing it in LateUpdate().