-
Notifications
You must be signed in to change notification settings - Fork 450
Avoid allocations in NetworkedAnimator #12
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
Conversation
… in network animator.
This doesn't work. Animator parameters is not populated before runtime. You probably have to do a check if the array is null, if so, populate it with the parameters. |
…ll cached params when ownership to prevent another out-of-range.
Correct. Turns out you also have to remember to null the array when changing ownership. See update (and thanks for that virtual!) |
Why are you resetting the array when changing ownership? |
Just doing a null check wasn't sufficient when testing on HLAPI. It would get into the for loop, then get an index out of range when actually reading one of the parameters, which in some way makes sense if you've switched from serializing to deserializing or vice versa. Where I was previously initializing the parameters array I nulled it instead, but that left one out of range error when this happens on ownership change. So I moved it into the ResetParameterOptions and call it when a change happens. I added it to both overrides not based on testing per se. In HLAPI, they reset last sync time in NetworkTransform when auth is started, but not when it is stopped, so I observed errors when interpolation was used because I add and remove auth from objects. I don't know that we have the same issue here, but seemed safest to just do both. |
Is this relevant to the MLAPI? MLAPI has none of the connectionReady and observer issues that the HLAPI has. The reset seems unnecessary. Please try without the reset and get back to me. |
I would, but don't have a test project based on MLAPI yet. |
Alright, I'll give it a shot. |
From my very quick testing, it's not needed. This will simply make the NetworkedAnimator nonfunctional as the parameters set to be synced are all turned off. Take it out of the PR and create another issue if neccecary. After this merge I'll rewrite the Animator to follow the rest of the projects code standard and be a bit cleaner. |
…e not needed in MLAPI.
Thanks. I'll finish my test project ASAP. |
Avoid allocations in NetworkedAnimator
Replicate HLAPI patch in https://bitbucket.org/Unity-Technologies/networking/pull-requests/21/cache-animator-parameters-to-avoid/diff