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

public class Hammer : MonoBehaviour
{
    public Transform hammer;
    public Vector3 initialDirection;
    public float speed= 100f;
    // Start is called before the first frame update
    void Start()
    {
        //hammer = GetComponentInChildren<Transform>();
        initialDirection = hammer.transform.position;
    }

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

    }

    private void OnTriggerEnter(Collider other)
    {
        StartCoroutine(HammerMotion());
    }

    IEnumerator HammerMotion()
    {
        Debug.Log("attaque");
        hammer.transform.position = Vector3.MoveTowards(hammer.transform.position, transform.position, speed * Time.deltaTime);
        yield return new WaitForSeconds(1f);
        hammer.transform.position = Vector3.MoveTowards(hammer.transform.position, initialDirection, speed * Time.deltaTime);
    }
}
