|
Hi Can anyone help me with this problem please? How do you only Instantiate a gameobject only once when pressing a button once? As the example below will instantiate a gameobject every time that a specific button is pressed. Thank you for your help. var NPC_Guard : GameObject; function Update () { }
(comments are locked)
|
|
@mweldon is totally right, so it deserves a +1. It's a very easy task, indeed; he have only pointed you to this: Just implemented that and it still makes clones of the original prefab when the button is pressed. I only want the clones to be generated no more the 2 times than that.
Jan 27 '12 at 12:55 PM
Random Binaries
Whoops just realised some please ignore the previous comment.
Jan 27 '12 at 12:57 PM
Random Binaries
That's good. Let us know if there are other troubles.
Jan 27 '12 at 01:00 PM
BiG
(comments are locked)
|
|
How about add a local boolean variable, initialized to false, that is set to true when you press the button the first time and check the variable in your if statement. But that will only ensure that everytime the fire button is pressed a new instantiated object will be created. It doesn't solve my problem I don't think. Using the above example script could you maybe implement what you said. Maybe I've got the wrong end of the stick of what you are saying. It be better if you show me in code instead of saying it. Cheers
Jan 27 '12 at 12:33 PM
Random Binaries
Jan 27 '12 at 12:41 PM
Lo0NuhtiK
Yeah, Lo0NuhtiK, you just ninja'd me! =D
Jan 27 '12 at 12:46 PM
BiG
cue Bruce Lee sound effect-> "Wuuauaaaaaaa"
Jan 27 '12 at 12:48 PM
Lo0NuhtiK
^_^ (6 characters to go)
Jan 27 '12 at 12:51 PM
BiG
(comments are locked)
|

What do you mean??
You only want to instantiate ONE thing at a time rather than two things at once like your code does?
-OR-
You want to be able to push the button once, have it instantiate those two things up there at once, and then after that the button is a dead button and doesn't do anything anymore?
or what?
Yeah, it'd help if you only called Instantiate once, instead of twice.
I meant the ability to push the button once, have it instantiate the two things once, and then after that the button is a dead button and doesn't do anything anymore.