Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How do I make that my collected Coins show up in the GUI?

Discussion in 'Scripting' started by MrBubiFish, Jul 8, 2014.

  1. MrBubiFish

    MrBubiFish

    Joined:
    Jul 8, 2014
    Posts:
    1
    I'm trying to make that the Coins I collected show up as Points in the corner or something...

    I'm new to programing and this is my Coin destroyer script


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Coin : MonoBehaviour {
    5.  
    6.     void OnTriggerEnter2D(Collider2D other){
    7.  
    8.         if (other.tag == "Coin")
    9.        
    10.         if (other.gameObject.transform.parent) {
    11.        
    12.  
    13.             Destroy (other.gameObject.transform.parent.gameObject);
    14.            
    15.         } else {
    16.  
    17.             Destroy (other.gameObject);      
    18.         }
    19.     }
    20.    
    21. }
     
  2. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    First off, this is Unity gossip. You need to post in the development help section lower down in the forums.

    Second, That just destroys the coin. You will need a script that tracks the amount of coins collected and pass the information to your GUI to display it.