playMaker

Author Topic: FSM stuck in trigger event.  (Read 4468 times)

ryf9059

  • Full Member
  • ***
  • Posts: 100
FSM stuck in trigger event.
« on: September 08, 2013, 10:09:58 PM »
I'm making a FSM on a bullet to detect collision, it's going to check the hit object, if the object is valid then it will proceed with a trigger event that notify the hit object, it then spawns a particle effect and wait until it kills itself.

But while running I found a problem: the FSM has been stuck in the state of trigger event after hit the enemy. I have attach a screenshot of my FSM here.



Presumably the WEAPON - ON HIT gets triggered and the state should mitigate to BLAH instead. If NOT, it should move to FINISHED and continue with the next process. But it just stays there as you can see the trigger event check box is green. And interesting enough, it still spawns the particle even that action is under trigger event in this case should never be executed if stuck in trigger event action. Why is that?


Can someone help me out? Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSM stuck in trigger event.
« Reply #1 on: September 09, 2013, 05:49:24 AM »
Hi,

 Could it be a case where your object is totally unable to receive any more trigger, because it's out of reach? Are you positive that something hits that gameObject and that it is a valid rigidbody with a collider component set to "trigger" ? Maybe you should check for "collision" instead?

 Bye,

 Jean

ryf9059

  • Full Member
  • ***
  • Posts: 100
Re: FSM stuck in trigger event.
« Reply #2 on: September 09, 2013, 11:38:05 AM »
Could it be a case where your object is totally unable to receive any more trigger, because it's out of reach? Are you positive that something hits that gameObject and that it is a valid rigidbody with a collider component set to "trigger" ? Maybe you should check for "collision" instead?

It might be the case that I didn't receive the trigger at that time since trigger enter happened already by the time I get hit object information, in that case it should be trigger stay instead so my object didn't receive trigger enter event.

But even that the FSM should just ignore that trigger event and proceed to the next spawn particle (create object) action instead. But the fact is the particle spawns but the FSM is still in the previous action (green check box), which makes no sense.

I'm positive I have rigidbody on both of them

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: FSM stuck in trigger event.
« Reply #3 on: September 09, 2013, 11:50:05 AM »
I'm making a FSM on a bullet to detect collision, it's going to check the hit object, if the object is valid then it will proceed with a trigger event that notify the hit object, it then spawns a particle effect and wait until it kills itself.

But while running I found a problem: the FSM has been stuck in the state of trigger event after hit the enemy. I have attach a screenshot of my FSM here.

Presumably the WEAPON - ON HIT gets triggered and the state should mitigate to BLAH instead. If NOT, it should move to FINISHED and continue with the next process. But it just stays there as you can see the trigger event check box is green. And interesting enough, it still spawns the particle even that action is under trigger event in this case should never be executed if stuck in trigger event action. Why is that?


Can someone help me out? Thanks.

You only need one trigger event for the collision.

It is staying green because it runs every frame, a state will not run event FINISHED until all actions have actually finished or it is specifically called to run by an action in that state. Trigger Event is looking for a collision every frame so FINISHED will never fire. You might try the Collision Stay type but I think the logic flow is breaking this more than the action.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

ryf9059

  • Full Member
  • ***
  • Posts: 100
Re: FSM stuck in trigger event.
« Reply #4 on: September 09, 2013, 12:03:28 PM »
You only need one trigger event for the collision.

It is staying green because it runs every frame, a state will not run event FINISHED until all actions have actually finished or it is specifically called to run by an action in that state. Trigger Event is looking for a collision every frame so FINISHED will never fire. You might try the Collision Stay type but I think the logic flow is breaking this more than the action.

Got it, that sounds about right, Thanks. But I do have another question, shouldn't trigger enter be just one frame and trigger stay after that? Because it's running every frame and get stuck there it can't be trigger enter for all of them?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: FSM stuck in trigger event.
« Reply #5 on: September 09, 2013, 12:16:39 PM »
You only need one trigger event for the collision.

It is staying green because it runs every frame, a state will not run event FINISHED until all actions have actually finished or it is specifically called to run by an action in that state. Trigger Event is looking for a collision every frame so FINISHED will never fire. You might try the Collision Stay type but I think the logic flow is breaking this more than the action.

Got it, that sounds about right, Thanks. But I do have another question, shouldn't trigger enter be just one frame and trigger stay after that? Because it's running every frame and get stuck there it can't be trigger enter for all of them?

Give it a try and see how it works, trial and error reveals many things =) It should work with one as Enter, then another doing Stay but I'm not sure if that is the best way to arrange your FSM or not. You'll have to tinker around and see how it flows as there are many different ways to get the result you want.

I usually setup test environments to test things i'm working on in a controlled situation.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D