playMaker

Author Topic: Create number of objects[SOLVED]  (Read 2849 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Create number of objects[SOLVED]
« 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! :)
« Last Edit: September 10, 2013, 02:13:46 AM by jeanfabre »
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Create number of objects
« Reply #1 on: August 24, 2013, 12:24:02 PM »
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.)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Create number of objects
« Reply #2 on: August 24, 2013, 04:44:35 PM »
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!
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Create number of objects
« Reply #3 on: August 24, 2013, 04:52:17 PM »
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...

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Create number of objects
« Reply #4 on: August 24, 2013, 04:57:27 PM »
Yes, I have that! I just want it to automatically create the objects I want.
And no objects is added to the scene.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Create number of objects
« Reply #5 on: August 24, 2013, 05:00:13 PM »
I take it back!
It works :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Create number of objects
« Reply #6 on: August 24, 2013, 07:15:40 PM »
Great! :)