gamedev-pro / dmotion

DMotion - A high level Animation Framework for Unity DOTS
Other
491 stars 47 forks source link

Fix occasional error with AnimationStateMachineSystem #7

Closed AVeryLostNomad closed 2 years ago

AVeryLostNomad commented 2 years ago

With the code as it is on master I periodically get an error at runtime that looks like the following: The system DOTSAnimation.AnimationStateMachineSystem reads Latios.Kinemation.BoneOwningSkeletonReference via SampleNonOptimizedBones but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.

This appears to be happening because of the repeated references to the ClipSampler buffer and other components written to in multiple jobs.

By manually defining these jobs in IJobEntityBatch (instead of letting codegen convert them for us) we can tag the attributes that are conflicting with [NativeDisableContainerSafetyRestriction], which appears to remove the error case and assume concurrent writes/reads are safe. We don't do concurrent writing, so reading should be fine. This removes the error in my case.

Not sure if this is critically important, but for my particular setup (2020.3.36f1 with 0.5.3 of both dmotion and Latios and several other packages installed) it stops the error from happening and increases performance.