playMaker

Author Topic: Help with trigger zones and multiple targets  (Read 2042 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
Help with trigger zones and multiple targets
« on: December 09, 2013, 11:00:18 PM »
Hi,

OK, so I have a gameobject, which is surrounded by a few other gameobjects.

When I set the state of my first gameobject to active, I want to also activate the other objects that are in the vicinity.

My first attempt, has been to have a box collider as a trigger zone. It's small, and when my object becomes active, I scale my collider so that is covers the nearby objects. I've given all objects rigidbodys so I can check for their tags.

However this doesn't work. It's not recognising that object2 is in the trigger zone. Could this be because I'm only checking for object2 after my collider is scaled up and I'm somehow missing the 'On Trigger Entry'?
(I'm sending an event that Object1 is now active, and that's received on Object 2's FSM and it then checks for Trigger Entry).

Or is there a much simpler way of doing what I want to achieve, and I'm just being an idiot?  :)


edit: OK, I actually got this to work when I started with Object1's trigger collider  being large to begin with.  I guess it's just about sorting out the timings of events and scaling.

As this is now posted here though, I guess my question about better/more efficient ways of doing this is still valid  :)
« Last Edit: December 09, 2013, 11:03:16 PM by jess84 »

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Help with trigger zones and multiple targets
« Reply #1 on: December 09, 2013, 11:06:07 PM »
I wouldn't say you're being an idiot, as I was reading your question, I started thinking of solutions. My first try would be to do what you did.

Re-thinking the situation, I think there may be another solution that might work. When your first object becomes active, have it set a global variable (a boolean might work well). Attach "listeners" to the other neighboring objects which change states once that global boolean changes to active (you might need a new FSM for each object so as to not interfere with what you've already got going on.)

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Help with trigger zones and multiple targets
« Reply #2 on: December 09, 2013, 11:17:39 PM »
I like the idea of running global bools, and that would be a much easier way to go if my objects were in static positions.

I don't have moving objects now, but I'm not ruling out that I might in the future - so I think I'll go to go down the slightly move convoluted method of trigger zones  :-\

Is there a method for returning all gameobjects within a certain distance from a reference point? I'm just trying to think of alternatives to colliders.

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Help with trigger zones and multiple targets
« Reply #3 on: December 09, 2013, 11:29:18 PM »
Ah, I see what you mean. You need the activation of neighboring objects to be dynamic, based on which (if any) are close enough to the main object.

If scaling the collider zone isn't properly triggering the nearby objects into activation, I wonder if instead of scaling it, if you used the "add component" action, to add a larger collider. And then remove it once the activation sequence was complete, using "remove component".