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

public class CoconutSpawner : MonoBehaviour {

	public GameObject CoconutItem;
	public float selfDestroyTime;

	public void spawnCoconut() {
		GameObject newCoconut = Instantiate (CoconutItem, gameObject.transform.position, Quaternion.identity) as GameObject;
		StartCoroutine (selfDestroy (newCoconut));
	}

	IEnumerator selfDestroy(GameObject target) {
		yield return new WaitForSeconds (selfDestroyTime);
		Destroy (target);
	}
}
