void OnTriggerEnter(Collider c) { if (c.tag.Equals("Player")) { PlayerStats ps = c.GetComponent <PlayerStats> (); PlayerCollectables pc = c.GetComponent <PlayerCollectables> (); if (hasHealthItem) { ps.updateHealth(10); } if (hasMaxHealthItem) { ps.addToMaxHealth(5); ps.updateHealth(10); } if (hasGemItem) { pc.updateGems(5); } if (hasCoinItem) { pc.updateCoins(5); } gameObject.SetActive(false); Destroy(gameObject); } }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerAmmo = player.GetComponent <PlayerAmmo> (); PlayerHealth = player.GetComponent <PlayerHealth> (); playerCollectables = player.GetComponent <PlayerCollectables> (); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; switchNum = 6; } else if (instance != this) { Destroy(gameObject); } player = GameObject.FindGameObjectWithTag("Player"); playerCollectibles = player.GetComponent <PlayerCollectables> (); }
// Use this for initialization void Start() { startPosition = door.transform.position; currentPosition = startPosition; collectables = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerCollectables> (); }