Null Reference Exception Error

nitrox32

Member
I have a scene set up with one enemy and one player in third person. The player is armed with a sword and the enemy is controlled by BD and simply set to wander. After I kill the enemy, upon it respawning I get the following error:

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Character.AnimatorMonitor.SetItemStateIndexParameter (Int32 slotID, Int32 value) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/AnimatorMonitor.cs:806)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdateItemAbilityAnimatorParameters (Boolean immediateUpdate) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1193)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnImmediateTransformChange (Boolean snapAnimator) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1913)
Opsive.UltimateCharacterController.Events.InvokableAction`1[System.Boolean].Invoke (Boolean arg1) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/InvokableAction.cs:87)
Opsive.UltimateCharacterController.Events.EventHandler.ExecuteEvent[Boolean] (System.Object obj, System.String eventName, Boolean arg1) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/EventHandler.cs:392)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.SetPositionAndRotation (Vector3 position, Quaternion rotation, Boolean snapAnimator) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1716)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.SetPositionAndRotation (Vector3 position, Quaternion rotation) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1685)
Opsive.UltimateCharacterController.Traits.Respawner.Respawn () (at Assets/Opsive/UltimateCharacterController/Scripts/Traits/Respawner.cs:142)
Opsive.UltimateCharacterController.Traits.CharacterRespawner.Respawn () (at Assets/Opsive/UltimateCharacterController/Scripts/Traits/CharacterRespawner.cs:36)
Opsive.UltimateCharacterController.Game.ScheduledEvent.Invoke () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:80)
Opsive.UltimateCharacterController.Game.Scheduler.Invoke (Opsive.UltimateCharacterController.Game.ScheduledEventBase scheduledEvent, Int32 index) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:657)
Opsive.UltimateCharacterController.Game.Scheduler.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:308)



The enemy continues to behave normally except I can't kill it after it respawns. I'm using the current version of BD and UCC as well as Unity 2018.2.11f1.
 
Are you able to reproduce this error within a demo scene or upload a scene that I can reproduce it with?
 
I can't reproduce in a demo scene. But I think it has something to do with changing a character's layer. What I would like to do is attach a point light to my character that follows him and only illuminates him. So I add my light, cull out everything except my character. The error in my game happens when I change the enemy's layer to something other than the "Character" layer. In the demo scene that I'm attaching everything is fine until I change the enemy's layer. And while the error that I described in my game doesn't appear in this scene, the enemy's behavior upon death and respawn becomes strange. Perhaps they are related somehow.
 

Attachments

  • Scene3.zip
    32 KB · Views: 1
Can you include your ItemCollection and ItemCollection.meta files as well? Once I import the scene do I need to do anything to repro the error?
 
Here they are. To reproduce the error change the layer of the layer of the enemy to something else. The behavior of the enemy becomes strange after the first death and in subsequent ones. For instance the ragdoll effect seems to randomly force the enemy into the floor and the enemy respawns from the sky. When I change back to the original layer the behavior persists. Also, when I try changing the player's layer and attack he starts rising into the sky indefinitely. This behavior also persists after changing back. This is a demo scene I created and not my game scene. I can't reproduce the error in this demo scene but I'm wondering if the two might be related.
 

Attachments

  • MyItems.zip
    766 bytes · Views: 0
I changed the layer of the enemy AI to the Water layer and upon respawn the agent acted normally. If you can list how to reproduce it from your demo scene that would really helpful.
 
Got it! I was changing the enemy and all of it's children, rig and everything else to the new layer. I should only be changing the object only not the object and it's children. This took care of the demo scene problems and the original error in my project. One other quick question as I'm sure I'm missing something simple. When my player is attacking and moving at the same time only the upper body animation plays. The legs don't animate. How do I get the legs to animate while the player is attacking and moving?
 
Top