- Home /
how can I interact and make an object go disappear
Hello
I have designed a 3rd person mobile(Android) game and every thing is fine except one thing. There are multiple hidden objects in the game and I want them to disappear after my character find them and interacts with them. I have also added an Interact button so the player can touch it. what I have problem with is the interaction and disappearance. I don't know how to make my character interact with an object and as the result the object disappear by touching the interaction button I have created.
Thanks for your help.
Answer by Smurfj3 · Dec 15, 2019 at 10:17 PM
The interact button could have a trigger collider to know whether your close enough to the button. To make a object disappear you can either disable the object so you can re-use it or you can destroy. To disable "this.gameobject.SetActive(false);" to destroy Destroy(this.gameobject);
https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html
https://docs.unity3d.com/ScriptReference/Object.Destroy.html
https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
These links will provide you with information you need to create what you want.
Your answer
Follow this Question
Related Questions
Help with 3rd person character picking up weapons? 0 Answers
User-Placeable Objects 1 Answer
NPC conversations- do I need to script my own system? 2 Answers
webgl app is not working in browser 0 Answers