playMaker

Author Topic: Check for visible objects with TAG[SOLVED]  (Read 3173 times)

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Check for visible objects with TAG[SOLVED]
« on: December 30, 2016, 04:37:02 AM »
Hi guys,

is is possible to make an action that would check if any objects with TAG are visible or not and then move to the following action if TRUE or no if FALSE?

I am using Core GameKit and i want to fire custom events based on the info is any enemies are visible on the screen or not.
« Last Edit: January 23, 2017, 01:22:16 AM by jeanfabre »
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Check for visible objects with TAG
« Reply #1 on: December 30, 2016, 09:10:08 AM »
Something like this

http://hutonggames.com/playmakerforum/index.php?topic=8417.msg40305#msg40305

but with tag filter. Can it be done through arraymaker perhaps? gameobject.findobjectsbytag returns an empty array if no objects with tag are found, but i don't know how to make an action out of it -_-

When i think of it, it doesn't even have to check the visibilty, since i made enemies despawn when they leave the screen.
« Last Edit: December 31, 2016, 04:02:16 AM by krmko »
Available for Playmaker work

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Check for visible objects with TAG
« Reply #2 on: December 31, 2016, 03:55:07 AM »
can you have the objects themselves check if they are on screen and if so add themselves to an array?
you could run GameObjectCompareTag beforehand if thats relevant

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Check for visible objects with TAG
« Reply #3 on: December 31, 2016, 05:58:18 AM »
That's not a bad idea, but there's a catch - if any objects are visible, and thus added to the array, the array should be emptied before the next check.

The system is organized like this: enemy objects spawn outside the screen (not visible) and have their stuff activated when visible and despawn when not visible again. The thing is, it's an endless wave system, and the check if objects with tags are visible should kick in after a set amount of time, after which the check would have to be done again after few seconds, until the empty array detected starts a custom event, so the array should be emptied before every next check.
Available for Playmaker work

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Check for visible objects with TAG
« Reply #4 on: January 01, 2017, 05:09:27 AM »
I'm not following why the array should be emptied? Shouldn't that be the case only after everything has despawned?

My suggestion:
Enemy is spawned, adds itself to array.
Enemy checks if is visible, if so, activates behaviors.
Enemy checks if it is not visible, if so, removes itself from array and despawns.

The array itself can send events every time something is added/removed, so that can be the trigger for counting the array, and at zero that means the wave is over.

Don't forget to remove the enemy from the array on its death too!

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Check for visible objects with TAG
« Reply #5 on: January 01, 2017, 08:45:50 AM »
Well, if i remove the enemy from an array when it despawns, then i don't have to empty an array, i haven't thought of it  ;D I'll try it out, never worked with arrays though.

But i'd also like the action to check IsVisible with tag filter and true/false state jump :)
Available for Playmaker work

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Check for visible objects with TAG
« Reply #6 on: January 02, 2017, 10:33:45 AM »
Just wanted to let you know i've done it with arraymaker, quite a handy tool!

Thanks for the help, terri ;D
Available for Playmaker work