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

public class PlayerSwap : MonoBehaviour
{
    private InputControls inputControls;
    private InputActionMap currentActionMap;
    public Animator animator;
    public Animator antherAnimator;

    public PlayerSwap anotherSwap;

    private void Awake()
    {
        inputControls = new InputControls();
        PlayerInput playerInput = GetComponent<PlayerInput>();
        currentActionMap = playerInput.currentActionMap;
    }

    void Start()
    {
        currentActionMap.FindAction("Swap").started += _ => Swap();
    }

    void Swap() 
    {
        animator.SetTrigger("swap");
        antherAnimator.SetTrigger("swap");
        Vector3 tempPosition = gameObject.transform.position;
        gameObject.transform.position = anotherSwap.gameObject.transform.position;
        anotherSwap.gameObject.transform.position = tempPosition;
    }
}
