[Bug] AutoSpawnDestroyRuntimeCharacterItems disrupts initialization order

WeiYiHua

Member
Bug :
1. Create a new project with Unity 2021.3.13f1.
2. Download and install Third Person Controller 3.0.3, Ultimate Inventory System 1.2.12, and Integration.
3. Open Integration Demo scene.
4. Check AutoSpawnDestroyRuntimeCharacterItems.
1669969048906.png
5. Add an item with Animator to Equippable.
1669969148081.png
6. Run the scene.
1669969413300.png

Error:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Character.ChildAnimatorMonitor.SnapAnimator (System.Boolean executeEvent) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/ChildAnimatorMonitor.cs:253)
Opsive.UltimateCharacterController.Character.ChildAnimatorMonitor.OnImmediateTransformChange (System.Boolean snapAnimator) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/ChildAnimatorMonitor.cs:640)
Opsive.Shared.Events.InvokableAction`1[T1].Invoke (T1 arg1) (at <f8e88e939b08494e9e6a74df2ca4dcad>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1] (System.Object obj, System.String eventName, T1 arg1) (at <f8e88e939b08494e9e6a74df2ca4dcad>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnEnable () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:454)

This is caused by ChildAnimatorMonitor.Awake() being called before AnimatorMonitor.Awake() when Instantiate the prefab.
 
Thank you for the bug report.
The correct way to equip an item on spawn is using a CharacterLoadoutItemCollection
1669976961684.png

So for now you can do this as a workaround until we fix the error.
 
Top