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

public class Coin : MonoBehaviour {

    public static Coin instance;

    public GameObject coin;

	void Start () {
        MakeInstance();	
	}

    void MakeInstance() {
        if (instance == null) {
            instance = this;
        }
    } 
	
	void Update () {
       
	}

    public void SpawnCoin() {
        GameObject player = GameObject.Find("Player");
        if (player != null) {
            GameObject coins = Instantiate(coin, transform.position, transform.rotation) as GameObject;
            Vector2 direction = player.transform.position - coins.transform.position;
            coins.GetComponent<CoinScript>().SetCoinDirection(direction);
        }
    }
}
