Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class CoinsBahavior : MonoBehaviour {
  7.  
  8.     public int value = 1;
  9.     private GameObject UI;
  10.     public Animator animator;
  11.     // Use this for initialization
  12.     void Start () {
  13.         UI = GameObject.FindGameObjectWithTag("CoinAmount");
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.        
  19.     }
  20.  
  21.     void OnTriggerEnter2D(Collider2D col){
  22.         if(col.gameObject.CompareTag("Player")){
  23.             int coinUI = int.Parse(UI.GetComponent<Text>().text) + value;
  24.             UI.GetComponent<Text>().text = coinUI + "";
  25.         animator.SetBool("IsColect", true);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement