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

public class triggerDestroy : MonoBehaviour {
	Animation anim;
	bool animCheck;
	// Use this for initialization
	void Start () {
		anim = gameObject.GetComponent<Animation> ();
		animCheck = false;//noPlayning
	}
	
	// Update is called once per frame
	void Update () {
		if (animCheck) {
			if (!anim.isPlaying) {
				print ("end");
				animCheck = false;//noanimPlay
				Destroy(this.gameObject);
			}
		}
		
	}
	void OnTriggerEnter(Collider other) {
		//Debug.Log ("ON");
		if (!anim.isPlaying) {
		anim.Play ();
		animCheck = true;//Playing
		}

	}


}
