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

public class SlidingDoor : Triggerable
{
    private Vector3 initialPos;
    private bool isOpen = false;
    [SerializeField]
    private Transform openPos;
    [SerializeField]
    private float openSpeed;

    // Start is called before the first frame update
    void Start()
    {
        initialPos = transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        if(isOpen){
            transform.position = Vector3.Lerp(transform.position, openPos.position, openSpeed*Time.deltaTime);
        }else{
            transform.position = Vector3.Lerp(transform.position, initialPos, openSpeed*Time.deltaTime);
        }
    }

    public override void TriggerEvent(){
        
        isOpen = !isOpen;
    }
}
