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

public class ReturnToStartPosition : MonoBehaviour
{
    Vector3 startPosition;
    void Start()
    {
        startPosition = transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        // return if object falls below a threshold
        if(transform.position.y < -25f)
        {
            // if there's a rigid body, we'll need to reset that too
            Rigidbody rb;
            if (transform.TryGetComponent<Rigidbody>(out rb))
            {
                rb.velocity = rb.angularVelocity = Vector3.zero;
            }
                

            // teleport obj to start position
            transform.position = startPosition;
        }
    }
}
