puksometron
Member
Hi,
For some reason, whenever the OnDeath event is raised, the attacker GameObject is always null:
Whenever the player shoots at a bot, the final shot right before the bot dies will not fire, and this error occurs. Then the player can no longer fire a weapon. It seems the stacktrace does mention the ShootableWeapon class, so I'm assuming this problem is part of this error. My OnDamage event looks like this:
I am registering it within the Start function like so:
I have also tried manually assigning the event directly under the Health component for the prefab, but the same error occurs. Is this some kind of bug, or have I done something wrong here? Any assistance would be greatly appreciated.
For some reason, whenever the OnDeath event is raised, the attacker GameObject is always null:
Code:
NullReferenceException: Object reference not set to an instance of an object
Game.Core.Managers.CharacterManager.OnDeath (UnityEngine.Vector3 position, UnityEngine.Vector3 force, UnityEngine.GameObject attacker) (at Assets/Scripts/Managers/CharacterManager.cs:124)
Opsive.Shared.Events.InvokableAction`3[T1,T2,T3].Invoke (T1 arg1, T2 arg2, T3 arg3) (at <27da9e1afec54f2fb2a11d46a234f9df>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1,T2,T3] (System.Object obj, System.String eventName, T1 arg1, T2 arg2, T3 arg3) (at <27da9e1afec54f2fb2a11d46a234f9df>:0)
Opsive.UltimateCharacterController.Traits.Health.Die (UnityEngine.Vector3 position, UnityEngine.Vector3 force, UnityEngine.GameObject attacker) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/Health.cs:493)
Opsive.UltimateCharacterController.Traits.CharacterHealth.Die (UnityEngine.Vector3 position, UnityEngine.Vector3 force, UnityEngine.GameObject attacker) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/CharacterHealth.cs:97)
Opsive.UltimateCharacterController.Traits.Health.OnDamage (Opsive.UltimateCharacterController.Traits.Damage.DamageData damageData) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/Health.cs:410)
Opsive.UltimateCharacterController.Traits.CharacterHealth.OnDamage (Opsive.UltimateCharacterController.Traits.Damage.DamageData damageData) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/CharacterHealth.cs:81)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Traits.PunHealthMonitor.OnDamageRPC (System.Single amount, UnityEngine.Vector3 position, UnityEngine.Vector3 direction, System.Single forceMagnitude, System.Int32 frames, System.Single radius, System.Int32 originatorPhotonViewID, System.UInt32 hitColliderID, System.Int32 hitItemSlotID) (at Assets/Plugins/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Traits/PunHealthMonitor.cs:97)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Plugins/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:553)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, Photon.Realtime.Player player, System.Boolean encrypt, System.Object[] parameters) (at Assets/Plugins/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:1266)
Photon.Pun.PhotonNetwork.RPC (Photon.Pun.PhotonView view, System.String methodName, Photon.Pun.RpcTarget target, System.Boolean encrypt, System.Object[] parameters) (at Assets/Plugins/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2940)
Photon.Pun.PhotonView.RPC (System.String methodName, Photon.Pun.RpcTarget target, System.Object[] parameters) (at Assets/Plugins/Photon/PhotonUnityNetworking/Code/PhotonView.cs:604)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Traits.PunHealthMonitor.OnDamage (System.Single amount, UnityEngine.Vector3 position, UnityEngine.Vector3 direction, System.Single forceMagnitude, System.Int32 frames, System.Single radius, Opsive.UltimateCharacterController.Traits.Damage.IDamageOriginator originator, UnityEngine.Collider hitCollider) (at Assets/Plugins/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Traits/PunHealthMonitor.cs:68)
Opsive.UltimateCharacterController.Traits.Health.Damage (Opsive.UltimateCharacterController.Traits.Damage.DamageData damageData) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/Health.cs:312)
Opsive.UltimateCharacterController.Traits.Damage.DamageProcessor.Process (Opsive.UltimateCharacterController.Traits.Damage.IDamageTarget target, Opsive.UltimateCharacterController.Traits.Damage.DamageData damageData) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Traits/Damage/DamageProcessor.cs:170)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.HitscanFire (System.Single strength) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:1001)
Opsive.Shared.Game.SchedulerBase.AddEventInternal[T] (System.Single delay, Opsive.Shared.Game.ScheduledEventBase+InvokeLocation invokeLocation, System.Action`1[T] action, T value) (at <6b6b48297d4f49e9ba244a49e70e6e92>:0)
Opsive.Shared.Game.SchedulerBase.Schedule[T] (System.Single delay, System.Action`1[T] action, T value) (at <6b6b48297d4f49e9ba244a49e70e6e92>:0)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Fire (System.Single strength) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:783)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.UseItem () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:691)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.LateUpdate () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:651)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateActiveAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities, System.Int32& abilityCount) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1057)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateUltimateLocomotion () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1043)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdatePositionAndRotation () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:858)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.UpdatePositionAndRotation (System.Boolean fromAnimatorMove) (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:527)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.OnAnimatorMove () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:1503)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnAnimatorMove () (at Assets/Plugins/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1786)
Whenever the player shoots at a bot, the final shot right before the bot dies will not fire, and this error occurs. Then the player can no longer fire a weapon. It seems the stacktrace does mention the ShootableWeapon class, so I'm assuming this problem is part of this error. My OnDamage event looks like this:
C#:
Debug.Log(attacker.name);
if (CharacterState != CharacterState.Incapacitated) CharacterState = CharacterState.Incapacitated;
I am registering it within the Start function like so:
C#:
EventHandler.RegisterEvent<Vector3, Vector3, GameObject>(gameObject, "OnDeath", OnDeath);
I have also tried manually assigning the event directly under the Health component for the prefab, but the same error occurs. Is this some kind of bug, or have I done something wrong here? Any assistance would be greatly appreciated.