playMaker

Author Topic: Trigger2d Event issue  (Read 1058 times)

Rfdshir

  • Playmaker Newbie
  • *
  • Posts: 3
Trigger2d Event issue
« on: November 15, 2020, 07:18:43 AM »
Unity 2017.4.40
Playmaker 1.9.0 p4
When Game Object in the Trigger2d Event changes in runtime, the action continue to detect collisions for the previous Game Object, not for the new one.
I've add "GetProxyComponent();   " in the OnEnter, and now it's work fine (don't know if it's a correct solution)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Trigger2d Event issue
« Reply #1 on: November 15, 2020, 01:44:16 PM »
Hi.
Maybe something in your logic

Rfdshir

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Trigger2d Event issue
« Reply #2 on: November 15, 2020, 06:19:26 PM »
I've try it on simplest example (screen in attachement). When the OnTriggerEnter2D Event happen and Obj var changes to Game Object (2) in State2, the Trigger2d Event continues to recieve collisions from the Game Object (1). Idk, maybe I'm doing something wrong, or this is one of the Unity bug. :-\
But when I've add one line of code - same FSM begun to work fine. I'm not a programmer though.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Trigger2d Event issue
« Reply #3 on: November 16, 2020, 01:01:28 PM »
Hi.
This will get the proxy component every time you enter the action.

The GetProxyComponent in this part will not trigger as it already has set one, meaning its not null.

Code: [Select]
        if (cachedProxy == null)
            GetProxyComponent();


Its not advisable to change them during runtime.

but if you really need to, then try this instead :

Code: [Select]
            if (cachedProxy.gameObject != gameObject.GameObject.Value)
                GetProxyComponent();

instead of the part that you added.

also put it above the update callback


Rfdshir

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Trigger2d Event issue
« Reply #4 on: November 16, 2020, 10:47:28 PM »
Thank you very much!