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

public class RespawnGeneric : MonoBehaviour {


	protected Vector3 respawnPos;
	protected Quaternion respawnRot;

	// Use this for initialization
	protected void Start () {

		respawnPos = transform.position;
		respawnRot = transform.rotation;

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

	public void ResetToSpawn()
	{
		transform.position = respawnPos;
		transform.rotation = respawnRot;

		if (gameObject.GetComponent<Rigidbody2D> () != null) {

			gameObject.GetComponent<Rigidbody2D> ().velocity *= 0;
			gameObject.GetComponent<Rigidbody2D> ().bodyType = RigidbodyType2D.Dynamic;

		}


		if (gameObject.tag == "Player") {
			gameObject.GetComponent<PlayerFlyScript> ().SuccessfullyRespawned ();
		}

	}
}
