How to interact with doors in my game?

I like the style of doors in Resident evil games and on the surface they don’t look like they would be too complicated. I am struggling to get my head around Unity’s new input system and how to link up my main player script, and a door script which I’m not sure how should be made. I have made the animation for the door to be opened and closed but don’t really know how to link them all together.
Any help would be appreciated :slight_smile:

Main Script

using System;
using System.Diagnostics.Contracts;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;

public class Player : MonoBehaviour
    [SerializeField] float mouseSensitivity = 3f;
    [SerializeField] float movementSpeed = 5f;
    [SerializeField] float mass = 1f;
    [SerializeField] float acceleration = 20f;
    public Transform cameraTransform;

    public Vector3 moveDirection =;
    Vector2 rotation =;

    public float Height
        get => controller.height;
        set => controller.height = value;

    public event Action OnBeforeMove;

    internal float movementSpeedMultiplier;

    CharacterController controller;
    internal Vector3 velocity;
    Vector2 look;

    PlayerInput playerInput;
    InputAction moveAction;
    InputAction lookAction;
    InputAction sprintAction;

    void Awake()
        controller = GetComponent<CharacterController>();
        playerInput = GetComponent<PlayerInput>();
        moveAction = playerInput.actions["move"];
        lookAction = playerInput.actions["look"];
        sprintAction = playerInput.actions["sprint"];
    void Start()
        Cursor.lockState = CursorLockMode.Locked;

    // Update is called once per frame
    void Update()

    void UpdateGravity()
        var gravity = Physics.gravity * mass * Time.deltaTime;
        //determines the vertical velocity
        velocity.y = controller.isGrounded ? -1f : velocity.y + gravity.y;

    Vector3 GetMovementInput()
        //takes horizontal and vertical input from the keyboard
        //var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");

        var moveInput = moveAction.ReadValue<Vector2>();

        var input = new Vector3();
        //input vector by adding the vector pointing from the player forwards, multiplied by 'y'
        //'w' and 's' keys
        input += transform.forward * moveInput.y;
        //input vector by adding the vector pointing from the player, to the right, multiplied by 'x'
        //'a' and 'd' keys
        input += transform.right * moveInput.x;
        //prevents the player from moving faster when moving diagonally 
        input = Vector3.ClampMagnitude(input, 1f);
        input *= movementSpeed * movementSpeedMultiplier;
        return input;
    void UpdateMovement()
        movementSpeedMultiplier = 1f;

        var input = GetMovementInput();

        var factor = acceleration * Time.deltaTime;
        velocity.x = Mathf.Lerp(velocity.x, input.x, factor);
        velocity.z = Mathf.Lerp(velocity.z, input.z, factor);

        controller.Move(velocity * Time.deltaTime);
    void UpdateLook()
        var lookInput = lookAction.ReadValue<Vector2>();
        look.x += lookInput.x * mouseSensitivity;
        look.y += lookInput.y * mouseSensitivity;

        look.y = Mathf.Clamp(look.y, -89f, 89f);

        //rotates the player object
        transform.localRotation = Quaternion.Euler(0, look.x, 0);
        //cannot do the same for the 'y' rotation as we need to angle the player object itself
        cameraTransform.localRotation = Quaternion.Euler(-look.y, 0, 0);