Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: QueenM56 on June 28, 2018, 06:40:09 AM

Title: Trigger 2D event problem[SOLVED]
Post by: QueenM56 on June 28, 2018, 06:40:09 AM
Hi all,

I have come across some problem with '2D trigger event' action...
I'm using the action to control my enemies, so setting is 'on stay' and sent event to attack the player (I've made sure checking the 'is a trigger' box).
The problem is it only trigger the 'attack' once, then the enemy will just hover on the player and do nothing. Only when the player makes a move, then it will trigger the attack again.
I've also tried using both 'on enter' and 'on stay' and it didn't make any difference.
Another thing I tried is to use '2D collision event' and the function works well. But What I need is for the enemy to just have the trigger collision shape with no rigid body.
Could anyone help to solve the problem?

Thanks,
M
Title: Re: Trigger 2D event problem
Post by: verybinary on June 28, 2018, 09:07:19 AM
sounds like a state flow problem?
any chance you could upload a screenshot of where the fsm gets stuck?
Title: Re: Trigger 2D event problem
Post by: QueenM56 on June 28, 2018, 10:06:45 PM
Hi verybinary,

Thanks for your comment.
I've attached 2 x screenshot, please see if you can tell anything wrong.
I don't think it's a state flow problem as the function works fine when I used 2D collation action. The problem only exists when I turn the object into a trigger and use 2D trigger event action.

everyone else, please help to have a look as well.

Thanks,
M
Title: Re: Trigger 2D event problem
Post by: QueenM56 on June 29, 2018, 03:47:42 AM
I spent several hours more on this but still couldn't figure out the problem.
It's like the 2D trigger on stay only triggers the action for one frame. Shouldn't it be triggering the action for every frame like collision 2D event?
Could it be bugs?

Please help me out someone, it's really killing me.

Thanks a lot.
M
Title: Re: Trigger 2D event problem
Post by: djaydino on June 29, 2018, 07:25:54 AM
Hi.
I can see only 1 image.

there might be an infinite loop, but i need to see the complete actions on both states to see what is going on :)
Title: Re: Trigger 2D event problem
Post by: QueenM56 on July 01, 2018, 10:13:10 PM
Hi djaydino,

I attached two screenshots here, please help to have a look.

Thanks!
M
Title: Re: Trigger 2D event problem
Post by: djaydino on July 02, 2018, 07:33:00 AM
Hi.
For triggers you need to use 'Trigger Event' on your image i can see that you are using 'Collision Event'
Title: Re: Trigger 2D event problem
Post by: QueenM56 on July 03, 2018, 06:28:26 AM
Yes, I'm currently using collision event as trigger even on stay is not working.
I used exactly same setting for trigger event and checked 'is trigger' box, but it only triggers attack once. I have to move my player then it will trigger the enemy attack again.
Could you possibly tell what the problem could be?

Thanks!
M
Title: Re: Trigger 2D event problem
Post by: DanielThomas on July 03, 2018, 06:51:31 AM
Not going to add much here more than I had similar problem with the "on stay" not working unless it's actually moving. It's like if the object inside trigger is not moving it's not updated. So possibly you could play around with the rigidbody settings.
Could you post a screenshot of the objects inspector as well?
Title: Re: Trigger 2D event problem
Post by: verybinary on July 03, 2018, 11:23:57 AM
Im on a similar tangent as @DanielThomas. there does seem to be "issues" involved with player movement.
try a copy of the trigger event right under the original and change it to trigger enter?

or you might have to just switch that out for a raycast from the enemy to detect the player
Title: Re: Trigger 2D event problem
Post by: djaydino on July 03, 2018, 01:13:10 PM
Hi.
I made a video trying to repo but it seems to work fine here.

Using unity 2018.1.3f1 and PlayMaker 1.9.0p3

Title: Re: Trigger 2D event problem
Post by: DanielThomas on July 03, 2018, 07:08:31 PM
Note that he's using 2D, which I also did when I had the problem. The rigid body 2D has a few different options like Dynamic, static etc. So it would be good to see the object's inspector.
Title: Re: Trigger 2D event problem
Post by: djaydino on July 03, 2018, 07:36:42 PM
Hi.

Oops thank for noticing, i will test on 2D.
Title: Re: Trigger 2D event problem
Post by: djaydino on July 03, 2018, 08:04:17 PM
Hi.
I can Confirm this.
It only triggers 'on stay' while object is moving.

Tried on u5.6.4 and latest official.

I will contact Alex.
Title: Re: Trigger 2D event problem
Post by: QueenM56 on July 03, 2018, 10:16:11 PM
Thanks guys,

Here is the screenshot of the inspector.
Please see if there is anything I should adjust.

Cheers,
M
Title: Re: Trigger 2D event problem
Post by: djaydino on July 04, 2018, 03:40:37 AM
Hi.
Ok it is not a bug actually.


You will need a rigidbody2D
And on the rigidbody2D you will need to set 'Sleeping Mode' to "Never Sleep"
and i believe Simulated must be checked.
Title: Re: Trigger 2D event problem
Post by: DanielThomas on July 04, 2018, 02:05:14 PM
I was going to suggest Rigidbody2D, but it was mentioned it actually triggered once and everytime the player is moving, so it must already have a Rigidbody, no? Can you show the inspector of the player as well? (Since it's the player entering, it's the one that would need the rigidbody)
Title: Re: Trigger 2D event problem
Post by: QueenM56 on July 04, 2018, 11:35:50 PM
Hi guys,

Thank you all so much, especially @djaydino!
The problem actually is the 'sleeping mode' setting.
I tried to add Rigidbody before, but put it on 'start awake' mode.
After I changed it to 'never sleep' everything seems working now!
Those who have the same problem should check your 'Sleeping mode' setting.

Thanks again!
M