Skip to content

Instantly share code, notes, and snippets.

@JonathanYin
Created July 17, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanYin/c4319733289fed519d6685dece10a04f to your computer and use it in GitHub Desktop.
Save JonathanYin/c4319733289fed519d6685dece10a04f to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Coins : MonoBehaviour
{
//make a container for the heads up display
Pancam hud;
//public GameObject player;
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "Player1")
{
hud = GameObject.Find("Main Camera").GetComponent<Pancam>();
hud.IncreaseScore(30);
Destroy(this.gameObject);
}
else if (col.tag == "Player2")
{
hud = GameObject.Find("Main Camera").GetComponent<Pancam>();
hud.IncreaseScore2(30);
Destroy(this.gameObject);
}
}
}
@JonathanYin
Copy link
Author

In this Coin script, I used the same concept as that of my BonusPoints script, but increased the points given to 300.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment