using System.Collections;
using UnityEngine;

public class Ball : MonoBehaviour
{
    [HideInInspector]public Rigidbody2D rb;
    Vector3 startPosition;

    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        startPosition = transform.position;
    }
    public void Reset(float duration){
        StartCoroutine(CoroutineReset(duration));
    }

    IEnumerator CoroutineReset(float duration){
        float t=0;
        Vector3 pos1 = transform.position;
        Quaternion rot1 = transform.rotation;
        while (t < duration){
            t+=Time.deltaTime;
            transform.position = Vector3.Lerp(pos1, startPosition, t / duration);
            transform.rotation = Quaternion.Lerp(rot1, Quaternion.identity, t/duration);
            yield return null;
        }
    }
}
