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

public class GravityFall : MonoBehaviour
{
    private Vector3 initPos;

    private float timer = 0f;

    private float y;

    public float stopOffsetY = -3f;

    private float targetY;
    private void Awake()
    {
        initPos = transform.localPosition;

        targetY = initPos.y + stopOffsetY;
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    private void FixedUpdate()
    {
        timer += Time.fixedDeltaTime;
        y = 0.5f * (-9.8f) * (Mathf.Pow(timer, 2));
        transform.localPosition = initPos + new Vector3(0, y, 0);
        
        if (y <= (targetY))
        {
            this.enabled = false;
        }

       // print(timer+":"+Time.fixedDeltaTime);
    }
}
