- Home /
Question by
Ray020509 · May 29, 2021 at 05:15 AM ·
2d-platformerscripting beginnerplatformershop
Help! I don't know how to do this!,I don't know how to do this
Hi there! I'm making a 2D platformer games where you can collect coins and at the end of the level if you have 10 gold coins then you can go through the house. To make the player not be able to go through the house i made a 2D collider on the house. Basically if someone can try to give me a script that does the things i describe i would be grateful and if there is any other questions I can answer, and thanks in advance! This is my gold coin collection system script: using UnityEngine; using TMPro;
public class CoinPickup : MonoBehaviour { private float coin = 0;
public TextMeshProUGUI textCoins;
private void OnTriggerEnter2D(Collider2D other)
{
if(other.transform.tag == "Coin")
{
coin++;
coin++;
coin++;
coin++;
coin++;
coin++;
coin++;
coin++;
coin++;
coin++;
textCoins.text = coin.ToString();
Destroy(other.gameObject);
}
}
}
Note : Every Gold coins gives you 10 gold coins (kinda confusing i know)
Comment