playMaker

Author Topic: "On Trigger Stay" not working [SOLVED]  (Read 5061 times)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
"On Trigger Stay" not working [SOLVED]
« on: June 11, 2017, 03:14:19 PM »
My game's "win state" involves the Player entering a goal area.

When the Player enters and stays in this goal area, I'd like my game to understand this as its "win state" and load the next level.

I'm using a 'Trigger Event - On Trigger Stay' action to listen for when the Player enters the goal area.

The problem is: as soon as the Player's collider hits the goal area's, the next level loads- which I don't want.  I only want the next level to load when the Player enters and remains in the goal area for a small amount of time.

Any ideas??
« Last Edit: June 13, 2017, 12:35:25 PM by ItzArranT »

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: "On Trigger Stay" not working
« Reply #1 on: June 11, 2017, 07:14:09 PM »
yea trigger stay pretty much works the same as enter but you could add a wait action in another state to cause a delay for the amout of time you require, depends on what you want, you might want it to reset once the player leaves, having trigger  exit can do that.
« Last Edit: June 12, 2017, 03:48:39 AM by Carmichael »

stevecash83

  • Playmaker Newbie
  • *
  • Posts: 25
Re: "On Trigger Stay" not working
« Reply #2 on: June 11, 2017, 07:16:12 PM »
Try this:

FSM - Trigger Enter, event - State 2

In State 2, set 'Wait', with a timer that sends the event WIN after a duration.
In that same state, set a 'Trigger Exit' that sends an even 'EXIT' leading back to state 1.

That way, the 'Wait' will only work if the time runs out. But if the trigger is exited, the FSM restarts back to it's original state.

Hope that helps.

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: "On Trigger Stay" not working [SOLVED]
« Reply #3 on: June 12, 2017, 03:03:38 PM »
Thanks guys, I'll give it a try- appreciate the help!

(Really nice thinking stevecash83, just understood what you were getting at)
« Last Edit: June 13, 2017, 12:35:09 PM by ItzArranT »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: "On Trigger Stay" not working [SOLVED]
« Reply #4 on: June 16, 2017, 09:12:19 AM »
Hi,

 You should stay away from Trigger Stay and Collider Stay, and instead use enter and Exit events and maintain a boolean variables or simply move form states to states like that, it will be a lot easier to develop, because on trigger stay is called every frame and so your actions are constantly restarted, it's better to move to a clean state from a OnTriggerEnter and transit back to an empty state with OnTriggerExit.

 Bye,

 Jean