Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwitchNode driver update overridden by ControlDriver #18

Open
alex-Symbroson opened this issue Oct 27, 2022 · 1 comment
Open

SwitchNode driver update overridden by ControlDriver #18

alex-Symbroson opened this issue Oct 27, 2022 · 1 comment

Comments

@alex-Symbroson
Copy link

Hello there, I stumbled over this neat animation project and decided to give it a try
It was a bit of a struggle to understand the driver concept but I think I got it

Until I stumbled across an issue where a node driver update appeared to not be applied.
In my case I have multiple animation states in a single animation to reduce the overhead of creating animation scripts a bit
You only need to read the bold text below, the next two paragraphs are just to describe the context of the problem

in my case I have a temporary move (blocking) which can be performed when in the 'idle' or the 'crouching' state
I tried to achieve this by appending the blocking frames to the idle and the crouching animation, but they aren't reachable by default
the IDLE and the crouch animation loops between frame 0-2 and the blocking animation starts at frame 3-5
when going into blocking state the graph goes to a switch node which updates the idle and crouch driver to the 3 to start the correspondig blocking animation at frame 3

This did not work however and I struggled to find out why until I logged the objects HashCode along with each Set call in the ReanimatorState class.
This finally lead me to the source of the problem - the ResolveDriver method in the ControlDriver class always uses previousState to update nextState, but in my case the switch updated the driver variable in nextState but it got overridden by the previousState

To clarify - the issue appears to be that SwitchNode driver updates are overridden by ControlDriver.ResolveDriver in a single frame.
I'm not sure how to resolve this correctly or if this method is even intended to work in your library
My goal was to reduce the amount of animation scripts in some way
I'm looking forward to hear from you regarding this issue :)

thanks and best regards,
Symbroson

@alex-Symbroson alex-Symbroson changed the title DriverUpdate overridden SwitchNode driver update overridden by ControlDriver Oct 27, 2022
@alex-Symbroson
Copy link
Author

alex-Symbroson commented Oct 27, 2022

I added a series of debug logs in order to understand the resolution process - maybe it helps to understand what I tried to achieve

Text Log:

ra res1 state: 9 % 11
ra res2 state: 9                 # root switch - selects '9' for 'blocking'
ra t_root -> t_block
ra [nextState] merge2 idle = 4   # set block frame of idle animation
ra [nextState] merge2 crouch = 2 # set block frame of crouch animation
ra res1 t_crouch: 0 % 2
ra res2 t_crouch: 0
ra t_block -> p_idle             # 'block' SwitchNode selects idle animation node
ra [nextState] merge2 t_block = 0
ra [nextState] merge2 t_block = 0
ra res1 idle: 1 % 9              # ResolveDriver reads previousState
ra [nextState] set idle = 2      # ResolveDriver autoIncrement call
ra res2 idle: 1                  # ResolveDriver return value
ra cell: 1                       # dispalyed frame - I want this to be 4 from above
Full log
ra res1 state: 9 % 11
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:40)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:17)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra res2 state: 9
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:44)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:17)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra t_root -> t_block
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:18)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra -1373633132 merge2 idle = 4
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.ReanimatorState:Merge (Aarthificial.Reanimation.Common.DriverDictionary) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/ReanimatorState.cs:103)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:16)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra -1373633132 merge2 crouch = 2
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.ReanimatorState:Merge (Aarthificial.Reanimation.Common.DriverDictionary) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/ReanimatorState.cs:103)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:16)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra res1 t_crouch: 0 % 2
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:40)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:17)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra res2 t_crouch: 0
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:44)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:17)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra t_block -> p_idle
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:18)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra -1373633132 merge2 t_block = 0
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.ReanimatorState:Merge (Aarthificial.Reanimation.Common.DriverDictionary) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/ReanimatorState.cs:103)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:34)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Nodes.SwitchNode:Resolve (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/SwitchNode.cs:19)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra -1373633132 merge2 t_block = 0
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.ReanimatorState:Merge (Aarthificial.Reanimation.Common.DriverDictionary) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/ReanimatorState.cs:103)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:ResolveCel (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:40)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra res1 idle: 1 % 9
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:40)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:ResolveCel (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:41)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra -1373633132 set idle = 2
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.ReanimatorState:Set (string,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/ReanimatorState.cs:33)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:42)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:ResolveCel (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:41)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra res2 idle: 1
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.ControlDriver:ResolveDriver (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState,int) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Common/ControlDriver.cs:44)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:ResolveCel (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:41)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

ra cell: 1
UnityEngine.Debug:Log (object)
Aarthificial.Reanimation.Nodes.AnimationNode`1<Aarthificial.Reanimation.Cels.SimpleCel>:ResolveCel (Aarthificial.Reanimation.IReadOnlyReanimatorState,Aarthificial.Reanimation.ReanimatorState) (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Nodes/AnimationNode.cs:42)
Aarthificial.Reanimation.Reanimator:UpdateFrame () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:110)
Aarthificial.Reanimation.Reanimator:Update () (at Library/PackageCache/com.aarthificial.reanimation@228b69e451/Runtime/Reanimator.cs:96)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant