playMaker

Author Topic: Trigger event return a list of colliders?  (Read 921 times)

Dakk

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Trigger event return a list of colliders?
« on: March 03, 2017, 03:22:30 PM »
Hi, I am new to Playmaker so there may be an easy answer but I have looked for a while and can't seem to find a way to get a list of all colliders inside a trigger (box collider).  Multiple objects in the scene may begin life inside the collider so I don't think Get Trigger Info will work, and Trigger Event only stores a single collider.   

I am looking to get a list of all of the objects inside a trigger volume then sort them by their z pos, to do some processing.
Thanks in advance!

Ofonna

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: Trigger event return a list of colliders?
« Reply #1 on: March 03, 2017, 11:05:34 PM »
hi,

is the game starting out with all the objects in the collider?

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Trigger event return a list of colliders?
« Reply #2 on: March 04, 2017, 09:07:43 AM »
It sounds like you need an OverlapBox
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 690
    • View Profile
Re: Trigger event return a list of colliders?
« Reply #3 on: March 04, 2017, 09:20:16 AM »
You need an array. Try arraymaker (ecosystem). Store all the items in the array and then sort. That would be part of the answer.

Dakk

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Trigger event return a list of colliders?
« Reply #4 on: March 04, 2017, 09:27:18 AM »
For a little more context of the problem I am trying to solve: picture playing cards all laying face down on a table in different configurations some on top of others, I want to flip just the top cards over so they are face up.

I would have to cast a lot of rays to sort this out, due to small overlap situations.  Overlap Sphere would work, but take a lot of small spheres around the edges of the cards.

I initially started out using get Next Overlap Area physics2D- it worked on initialization fine, but I couldn't get it to update after the cards moved- it always returned a false positive of a card that used to be in the overlap area but had moved.  Also I was concerned about being locked into just 2d physics for the entire game as I don't think I could add 3d physics to the background scene.

Tcmeric, how would I get the list for the array?  "Trigger Event" just stores a single collider, and running it multiple times will not iterate through the colliders.  Get Trigger info returns the last event- but that doesnt work as mulitple colliders start inside the trigger on initialization.

Dakk

  • Playmaker Newbie
  • *
  • Posts: 15
    • View Profile
Re: Trigger event return a list of colliders?
« Reply #5 on: March 04, 2017, 01:44:29 PM »
I went back and looked at why Next Overlap Area 2D wasn't working- looks like there could be a bug. 

It works the first time you pass through the function, but doesn't reset the variables- so running it again after finding a collider will always result in false positives and a return of the previous collider(s).  It is possible I am not using it right and there is a way to reset the variables in the function.  Does anyone have any experience with this?
Thanks!