KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
68 stars 8 forks source link

"Event Being Modified" warning #346

Closed wrymn closed 6 months ago

wrymn commented 6 months ago

It seems I don't quite understand the transition, or state events. I tried every possible combination depending on what the console warning writes, checked out documentation and its still warning me something.

"Possible Bug Detected: The AnimancerEvent.Sequence being modified should not be modified because it was created by a Transition."

On my component Awake(), I use Clone() on a transition defined in scriptable object, so this component has its own instance.

Then I register OnEnd event for that transition, as I need to get notified when it ends.

But the warning is printed either when I register only once after I Clone() it in Awake() of component, or even when I unregister and register right after using Play() with my transition.

There is option to disable warning, but dont wanna do it yet as maybe really im doing something wrong.

image image

KybernetikGames commented 6 months ago

You're not alone there, figuring out the correct way to set up events in situations like that confuses a lot of people and will be changed in Animancer v8.0 to hopefully be much easier to use and understand (see Shared Events and Persistent Events).

For now though, your second screenshot where you're initializing the event on the transition in Awake should be correct. It shouldn't be possible for that to give the same warning. Try putting a log in AnimancerEvent.Sequence.SetShouldNotModifyReason and look at the stack trace to see what's causing it to get flagged for the warning early.

wrymn commented 6 months ago

Owner

I moved it to the Awake() and removed from everywhere else. I just now assign delegate like this

OnEnd = = () => {};

However, now I get warning about empty event

image

The SetShouldNotModifyReason() log originates when I Play() that transition.

actionLayer.Play(attackTransition);

KybernetikGames commented 6 months ago

However, now I get warning about empty event

That means you must have an event with no callback assigned. Check if you accidentally added one somewhere else.

The SetShouldNotModifyReason() log originates when I Play() that transition

That means you won't get the "AnimancerEvent.Sequence being modified" warning as long as you assign the event callbacks on the transition's events before that Play call.

wrymn commented 6 months ago

That means you must have an event with no callback assigned. Check if you accidentally added one somewhere else.

Indeed, I am marking all clip transitions with empty event, to mark when animation "strikes" target, but never use the event callback, just the time of event for calculations.

Setting callback fixed the issue, even though I dont really need the callback itself.

Thanks!