edited November 2019 in ORK Scripting
Hi,

Instead of using an Update() function to be noticed when the selecting combatant is changed in a battle, I've tried to use the ORK.Battle.SelectingCombatant.Changed event.

I created a Start Battle game event that is triggered every time a battle starts. In this event, there is a Call Function node that starts an ORKBattleStarted function on a custom component of a game object. In this function, I start a coroutine that checks if ORK.Battle.SelectingCombant is valid and when it is, it does:

ORK.Battle.SelectingCombatant.Changed += OnSelectingCombatantChanged;

Then, I have the OnSelectingCombatantChanged(Combatant c) function that does what it needs to do...

And of course, I remove the event in an OnDestroy() function.

When I play the scene, it works, but as soon as I move a combatant on the grid, Unity freezes. I placed a Debug.Log in the first line of the OnSelectingCombatantChanged function and it is never executed.

When I don't add my function to the delegate, everything works fine, so I'm sure the issue is related to that.

Any idea of what might cause this problem?
Post edited by ArsMagika on
  • Yeah ... that's not how this works - in fact, there's no event listener for the selecting combatant changing :)

    ORK.Battle.SelectingCombatant is the selecting combatant, so registering to ORK.Battle.SelectingCombatant.Changed will notify you if something on that combatant changed, not that the selecting combatant changed.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ahhh! Got it. Too bad, I'll simply revert to my Update function...
Sign In or Register to comment.