J's Study log

[Unity] Tag / Applied Learning(Eating Coins, Game Manager) 본문

Computer Language/Unity

[Unity] Tag / Applied Learning(Eating Coins, Game Manager)

정우섭 2019. 3. 4. 23:38

Use Material to change Coin Object's color and look. Make a new script for Coin Object and code Destroy(gameObject); in OnTriggerEnter function to make the Coin disappears. Add some other codes for the events you want to make happen.


After making few coins, you need to tag coins to administrate coins easily.



Click Add Tag in Inspector and make a Tag and you can separate objects easily Tag by Tag.

In script GameObject.Find("object name"); returns only one object, but GameObject.FindObjectsWithTag("tag name") returns list of object in tag.



So with this code you can use coin objects by coins[] list.



Game Manager


Game Manager is a script that administrates the whole game. It means that many events in other scripts are actually activated by Game Manager script. In this way we can control the game easier then using every scripts.



Use this code to return a message form other scripts functions.





'Computer Language > Unity' 카테고리의 다른 글

[Unity] UI  (0) 2019.03.06
[Unity] Pubilc  (0) 2019.03.06
[Unity] Trigger and Collision  (0) 2019.03.02
[Unity] Local Transform  (0) 2019.02.27
[Unity] Parents and Child Object  (0) 2019.02.27
Comments