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/605cc256e1e90189c1c53827960db1bd to your computer and use it in GitHub Desktop.
Save JonathanYin/605cc256e1e90189c1c53827960db1bd to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class BonusPoints : 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(10);
Destroy(this.gameObject);
}
else if (col.tag == "Player2")
{
hud = GameObject.Find("Main Camera").GetComponent<Pancam>();
hud.IncreaseScore2(10);
Destroy(this.gameObject);
}
}
}
@JonathanYin
Copy link
Author

This script creates a bonus-point pickup, and when a player collides with it and collects it, it will grant them 100 bonus points.

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