playMaker

Author Topic: [SOLVED] OnTrigger/CollisionSTAY - Help me be less stupid!  (Read 3440 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
This is more of a Unity question than a Playmaker question, but this community is more helpful and is usually quick to answer, so I'm going to ask it here:

Can someone please explain to me the use of OnTriggerStay?  My expectations for this action don't seem to be accurate, and I haven't been able to get my answer from the documentation.

I assumed it would detect whenever a collider is encompassed within a trigger volume.  I've tried using this for things such as detecting when my player object is complete submerged in water, or in the case of OnCollisionStay, any time my player object is continuously touching a specific surface, but in both cases (I've tried several experiments), it doesn't seem to operate that way.

What mistake am I making, and how is this feature actually supposed to work?  

Many thanks in advance.
« Last Edit: May 30, 2012, 11:15:59 AM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: OnTrigger/CollisionSTAY - Help me be less stupid!
« Reply #1 on: May 30, 2012, 02:26:27 AM »
Hi,

 On trigger stay is fired on each frame between the on trigger enter and on trigger exit event.

 I would recommend not to use this at all, and instead rely on the enter and exit events, and you simply maintain a boolean variable about the collision status.

I use it however for one very specific case. When the scene is starting and two colliders are already in contact, you will not receive the Enter event, so in the start state I watch for the trigger stay call, and if I get one, I treat it as an enter event, and then make no further use of the trigger stay event or action.

Hope that make sense.

What kind of usage do you want to do with this stay event?

 Bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: OnTrigger/CollisionSTAY - Help me be less stupid!
« Reply #2 on: May 30, 2012, 03:13:20 AM »
Hi,

Thanks very much for the explanation.  That makes sense, though I never saw the action fire when I tested it.  I use only enter/exit actions anyway, so knowing that 'Stay' doesn't do anything I'm not able to do already means I can forget about it. 

I didn't have any specific use in mind for this, but I thought knowing what it did and how it worked might give me one more tool to solve issues and fix bugs.  I guess my test for seeing if the player were completely within a volume of water would be one example, but as you've just shown - there's really no better way to do this than with enter/exit and a bool.

I guess the other reason was because I have a pretty good grasp on almost all things Unity/Playmaker now, except for that function!  It was really bothering me that I was never able to learn what those functions did, so I thought I'd make a post specifically for finding out once and for all.  :)

Thank you for the enlightenment!