Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Tobeee on December 21, 2012, 09:15:41 PM
-
Hi guys!
I am spawning objects randomly. So I have a "Create Object" action which has a "Random object" variable inside. I'd like to destroy this object after 5 seconds. I tried the "wait" (5 secs) and the "destroy self" action on each of the randomly spawend objects. The problem is that the objects destroy themselves so they can't be spawned any longer. Does anybody know a method on how to destroy a randomly generated object without destroying it's parent?
Thanks
Tobi
-
Ideas anybody? Please!
-
Sorry can you describe what you want a little better?
Cheers
-
Hi. I'll try ;)
I want to spawn one out of three obejcts randomly once a second. I want these randomly created objects to be deleted after five seconds.
What I did so far is:
Action: "Select Random Game Object" (Inside this action I select three objects from the hierarchy and store the game object in a game object variable.)
Next Action: "Create Object" (Here I select my game object variable and spawn it at a random position.)
Next Action: "Wait" (Here I wait for one second and then go back to the first action)
So after a while I have a lot of randomly created objects. Now I want them to destroy themselves, each after five seconds. I could use the destroy action on the objects inside the hierarchy but then I wouldn't be able to spawn any longer.
Any idea?
Thanks!
-
As long as your objects are prefabs, you should be able to do a "destroy self" on instances that doesn't affect the prefabs.
So you have to :
1. Create prefabs for the objects you want to create randomly with an attached script or fsm that does "Wait for 5 sec" "Destroy self"
2. Use the same way so used but choose the prefabs you created in "Select Random Game Object" instead of scene instances (choose them for the Assets tab and not from the Scene tab when you select the objects for "Select Random Game Object" action)
That should solve your problem :)