playMaker

Author Topic: Is there any way to find objects with tag and store to an array?  (Read 10042 times)

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
I guessing this is actually fairly simple, but I've been looking through all the actions and haven't found anything. What I'm trying to do would be the Playmaker version of this:

var spawnpoints : GameObject[] = GameObject.FindGameObjectsWithTag ("Spawnpoint");

I've looked at Arraymaker, but the problem seems to be that there's no playmaker action equivalent for FindGameObjectsWithTag. Any thoughts?

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Is there any way to find objects with tag and store to an array?
« Reply #1 on: May 08, 2013, 03:11:58 AM »
Hello,

How I do this when I want to get an object with a specific tag I use the "Get Random Object", specify the tag and then store it in a variable. It is random, but when I use the command usually I limit the tag to one object and that way I don't have to worry about the "random" part.

Hope that helps

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Is there any way to find objects with tag and store to an array?
« Reply #2 on: May 08, 2013, 04:11:33 AM »
Or you could use the "find Game Object" action (it has a tag option)
Then add that to an array, change the tag to something different and repeat until all gameobjects have been added :)

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Is there any way to find objects with tag and store to an array?
« Reply #3 on: May 08, 2013, 01:52:42 PM »
@LampRabbit: Thanks. That is indeed the process I was getting at. I'm not sure what you mean by "change the tag to something different" though. All the objects I'm trying to find have the same tag. I did figure out how to make an array and add objects to it using Arraymaker. The biggest problem I'm having now is that I can't figure out a way to iterate through all the tagged objects in the scene and count each one once. "FindGameObject" appears to only be able to find one object and then it stops. I'm pretty new to Playmaker though, so I'm probably just missing something.

@Vallar: Thank you, too. It probably won't work in all cases where I'm trying to get all objects with a tag, but in the case of choosing a spawnpoint, I think your suggestion will work perfectly. Having just started using this, I'm still trying to think too much like a programmer and was looking for the action equivalent to the scripting command. I didn't realize there was an action to just pick a random object.

Still, I was a little surprised that there isn't better integration in Playmaker for arrays. There is Arraymaker, and it does some cool things, but it would be nice if there was something like just a checkbox next to a variable that said "is array", or something like that, but Playmaker is a pretty solid program, so I'm guessing there are very good reasons for it being set up the way it is. Definitely no complaints.

Thanks again.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Is there any way to find objects with tag and store to an array?
« Reply #4 on: May 09, 2013, 03:22:01 AM »
Hi,

 here we go, I created an arrayMaker action for this.

http://hutonggames.com/playmakerforum/index.php?topic=3854.0

bye,

 Jean

Gevarre

  • Playmaker Newbie
  • *
  • Posts: 49
Re: Is there any way to find objects with tag and store to an array?
« Reply #5 on: May 09, 2013, 03:15:03 PM »
Thanks.
You really are amazingly fast :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Is there any way to find objects with tag and store to an array?
« Reply #6 on: May 10, 2013, 01:24:46 AM »
Hi,

 Creating custom actions is really not difficult, in this case, I't s 99% copy and paste, I I actually never start a custom action from scratch...

Bye,

 Jean