Quantcast
Channel: Latest Questions by Jack-Howard
Viewing all articles
Browse latest Browse all 17

How do you get sprite to appear on HUD when collected

$
0
0
I'm coding a 2D platformer in c#. I have a key and when collected i want the picture of the sprite to appear in the top right of the screen showing the player that they have collected the item.This is the code I have so far using UnityEngine; using System.Collections; public class KeyScript : MonoBehaviour { bool hasKey = false; void OnTriggerEnter2D(Collider2D other) { if(other.gameObject.tag == "Key") { Destroy(other.gameObject); hasKey = true; } } } " I think you would put a line under "hasKey = true;" but im not sure what the right words to use for this are. I was wondering if i attach a picture of the key to my HUD but turn the sprite renderer off if their was a line i could put in to turn it back on when the key is collected or if there is a different way to solve my problem. Many thanks

Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>