Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rabagast on August 24, 2013, 12:10:58 PM
-
Hi!
I want to create for example 10 Game Objects in the beginning of the game.
I tried to create an object and store it to an int variable, and set the value to 10, but I can't use int variable in a game object. How can I do this?
Thanks! :)
-
You have to make a loop. Make a state that creates one object, then loop through that state 10 times.
I've attached a simple example as a screenshot.
There's also a working example in PlayMakerSamples\TestLab\Spawning\SpawnGrid.
There's another example of a loop in PlayMakerSamples\GUI\Countdown.
I would play with a simple loop first just to get the hang of it. Once you get the hang of it you can do more work inside the loop (space the created objects out, pick a random spawn point etc.)
-
Hi!
Thank you!
Do you use the prefab object to create object? Nothing happened!
I also tried to use the object in the scene to create 10 more, but that was a mess!
-
Generally you would use a prefab. Note, that example will just put them all in the same place, it's just to illustrate the basic technique. You would need some other actions to position the spawned objects. There was a recent post about randomizing spawn positions that you could check out...
-
Yes, I have that! I just want it to automatically create the objects I want.
And no objects is added to the scene.
-
I take it back!
It works :)
-
Great! :)