playMaker

Author Topic: [SOLVED] How to find multiples objects.  (Read 1820 times)

Vanyfraise

  • Playmaker Newbie
  • *
  • Posts: 19
[SOLVED] How to find multiples objects.
« on: December 13, 2017, 06:00:31 AM »
Hi guys,

I'm searching for a non-developper friendly way to find multiples objects with tag or something else in my scene. I want to build a cancel bullet feature in my shmup. To do this, i have to find all existing bullets in screen and then deactivate them or thing like that.

Do I have to put all created bullet in an array or something like that ?

As Leeloo said, "Please help".
« Last Edit: February 13, 2018, 08:51:57 AM by Vanyfraise »

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: How to find multiples objects.
« Reply #1 on: December 13, 2017, 10:19:45 AM »
There are plenty of ways to do this, i use Pooly for stuff like this but there are also some great pooling actions on the ecosystem and you always want to use pooling when dealing with bullets.

In the Fsm where you fire/spawn your bullet just save a reference to it and store that reference into an array with a max lenght of about 10, that way you can always get the last 10 bullets fired and do a "for each" loop to destroy/despawn them.

(There are some great video's on youtube for learing arrays)

Alternatively you could also parent the bullets to a "Holder" object when spawning them and then use get child/get all children on that parent object.

But the first option would be the most logical thing to do.

Hope that helps
« Last Edit: December 13, 2017, 10:39:36 AM by LordHorusNL »

Vanyfraise

  • Playmaker Newbie
  • *
  • Posts: 19
Re: How to find multiples objects.
« Reply #2 on: December 13, 2017, 10:40:52 AM »
I avoid object pooling, always thought it was too complicate for me to play with but it seems i have to.

I'll try Pooly, thakn you !

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: How to find multiples objects.
« Reply #3 on: December 13, 2017, 10:49:12 AM »
Pooling is really easy, try the free pooling actions on the ecosystem before buying Pooly.

You can still do what you want without pooling offcourse, however pooling is always the smart thing to do when spawning many object like this.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: How to find multiples objects.
« Reply #4 on: December 13, 2017, 11:38:30 AM »
If it's not a design problem and bullets need to have a specific parent, that solutiin seems simplest, simply parent them under an object and then just despawn all children.
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to find multiples objects.
« Reply #5 on: December 13, 2017, 12:12:45 PM »
Hi.
You can add the bullets to an array when creating (or when enabling when pooling)
Then you can use array get next to loop thru them and destroy (or disable and place back in pool)

I do agree that it is best to use pooling as it is a lot better for performance.

Vanyfraise

  • Playmaker Newbie
  • *
  • Posts: 19
Re: [SOLVED] How to find multiples objects.
« Reply #6 on: February 13, 2018, 08:52:55 AM »
Thanks guys,
I tried "Simple Object Pooling", it works great.