playMaker

Author Topic: Destroying objects... [SOLVED, but confused]  (Read 4673 times)

Tkfore21

  • Playmaker Newbie
  • *
  • Posts: 11
Destroying objects... [SOLVED, but confused]
« on: August 01, 2013, 12:22:05 AM »
Ok, I know how to destroy objects, but not how to destroy objects which are not chosen from a random list selection.

Example:
- Start with 5 inactive objects
- I create an FSM using the "Get Random Object" action for all 5 items
- "Get Random Object" picks one object and assigns it to a variable
- Another state sets the one object to become active
- The rest stay inactive

I would rather destroy the other objects, but I'm not sure as to how this can be accomplished.  Any pointers, or ideas?  Any would help!
On a side note, can you pick more then one item from a random list without repeating an object?
« Last Edit: August 02, 2013, 12:47:26 PM by Tkfore21 »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Destroying objects...
« Reply #1 on: August 01, 2013, 12:27:24 AM »
Are you using array maker? Personally I'd take a look at using array maker if you arn't already, it sounds like you're after a flexable solution that can handle different situation (more gameobjects)

With array maker you can add gameobjects to an array, select a random gameobject, remove it from the array (and or do something to it) and then destroy all the other gameobjects still in the array. Sound like the answer?

Array maker is SO handy!

Tkfore21

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Destroying objects...
« Reply #2 on: August 01, 2013, 02:04:54 AM »
Looks like I will ned to learn arrays and ArrayMaker.  Any recommendations on where to start?  It's ground zero for me.

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Destroying objects...
« Reply #3 on: August 01, 2013, 02:17:24 AM »
I remember back when I first looked at it - I was very confused but now that I've used it heaps I can help you out.

First thing to do is add an ArrayList Proxy to an empty gameObject and take a look at it in the inspector window. Fill in the Reference with a name (just for good practice) and create an fsm to add some gameobjects to the array. Use Array List add, this will add gameobjects at runtime OR you can pre fill the array if you already know what to add and it isn't going to change.

From there I would take a look at 'Array List Get Random' 'Array List Get next' and just get them working.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Destroying objects...
« Reply #4 on: August 01, 2013, 02:52:09 AM »
Hi,

 thanks LampRabbit, I welcome other people wording their view of ArrayMaker to explain others :)

Tkfore21, Have a go, if you still struggle with using arrayMaker, let me knw, I'll do a simple example to demonstrate your case.


bye,

 Jean

Tkfore21

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Destroying objects... [SOLVED]
« Reply #5 on: August 01, 2013, 11:28:10 AM »
Marked as solved.  Thanks for all the advice!

Tkfore21

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Destroying objects...
« Reply #6 on: August 02, 2013, 12:47:14 PM »
Tkfore21, Have a go, if you still struggle with using arrayMaker, let me know, I'll do a simple example to demonstrate your case.
Jean-
I spend quite a while looking into ArrayMaker yesterday, last night and this morning, and I'm figuring out a little bit of it. But, I'm hoping you can create the example you mentioned above.  Thanks for your help on this.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Destroying objects... [SOLVED, but confused]
« Reply #7 on: August 05, 2013, 04:32:20 AM »
Hi,

 ok, please find a working sample. Basically the trick is to copy the items into a new array proxy, and as you pick random items from it, remove them, which means you will always pick a fresh one and never the same.

 as for destroying/creating opposed to hiding/showing, this is very much up to you to decide thet best way, knowing that creating object takes time so if you plan on doing this a lot, then you will want a proper pool manager to handle this effectivly.

bye,

 Jean