- Home /
Question by
SweetRevenge · Sep 10, 2010 at 12:26 AM ·
torch
Equip and Unequip a torch?
How can I do this. I attempted it with this script and it was a fail.
Comment
Please copy/paste your code in future. An inset image doesn't allow copy/pasting for ease of answering. Also, describing something as "a fail" doesn't much help detail the actual problem.
Best Answer
Answer by · Sep 10, 2010 at 04:16 AM
You're destroying the TorchPrefab link, rather than the 'torch' that you've instantiated. You want:
Destroy(torch);
Also, every time you press Fire2, you'll spawn a new torch. You could use a boolean to store whether or not the torch is spawned, and only allow a new one if it isn't (and only attempt to destroy it if one exists).
Answer by frank · Sep 10, 2010 at 04:13 AM
you could try this:
gameObject.renderer.enabled = true/false;
hope that could help a little