- Home /
Question by
Frank Hansen · Dec 02, 2010 at 04:17 PM ·
instantiatedestroykeyactiveenabled
Button to create object???
hi can anyone make me a script that does so when a player press a button on the keyboard (/) a object will get deleted/removed and when the button (*) is pressed on the keyboard the object will come back
Comment
Best Answer
Answer by Jesse Anders · Dec 02, 2010 at 06:11 PM
This forum isn't really about people writing complete scripts for you; for that, you might have better luck on the Unity 'Collaboration' forum.
As for your question though, I think the first question is, do you really need to destroy and recreate the object, or would it be sufficient simply to activate/deactivate it or enable/disable its visual components?
In either case, here are some things to look into:
- Input.GetKeyDown() and GetButtonDown()
- The Destroy() function
- The Instantiate() function
- GameObject.active
- renderer.enabled (that is, the enabled field of the renderer for a game object)