Ai Not Taking Damage

shehmir12

New member
Hi @Justin I am having a issue with Enemy AI on Mobile the agent is not taking any damage. I use Log viewer and I found this Error :

NullReferenceException: Object reference not set to an instance of an object

Opsive.Shared.Game.ObjectPoolBase.InstantiatedWithPoolInternal (UnityEngine.GameObject instantiatedObject) (at <3261d1d1480d44a1abe2cb945dc5a01c>:0)
Opsive.Shared.Game.ObjectPoolBase.InstantiatedWithPool (UnityEngine.GameObject instantiatedObject) (at <3261d1d1480d44a1abe2cb945dc5a01c>:0)
Opsive.UltimateCharacterController.Traits.Health.Die (UnityEngine.Vector3 position, UnityEngine.Vector3 force, UnityEngine.GameObject attacker) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Traits.CharacterHealth.Die (UnityEngine.Vector3 position, UnityEngine.Vector3 force, UnityEngine.GameObject attacker) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Traits.Health.OnDamage (System.Single amount, UnityEngine.Vector3 position, UnityEngine.Vector3 direction, System.Single forceMagnitude, System.Int32 frames, System.Single radius, UnityEngine.GameObject attacker, System.Object attackerObject, UnityEngine.Collider hitCollider) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Traits.CharacterHealth.OnDamage (System.Single amount, UnityEngine.Vector3 position, UnityEngine.Vector3 direction, System.Single forceMagnitude, System.Int32 frames, System.Single radius, UnityEngine.GameObject attacker, System.Object attackerObject, UnityEngine.Collider hitCollider) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Traits.Health.Damage (System.Single amount, UnityEngine.Vector3 position, UnityEngine.Vector3 direction, System.Single forceMagnitude, System.Int32 frames, System.Single radius, UnityEngine.GameObject attacker, System.Object attackerObject, UnityEngine.Collider hitCollider) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.HitscanFire (System.Single strength) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.Shared.Game.SchedulerBase.AddEventInternal[T] (System.Single delay, Opsive.Shared.Game.ScheduledEventBase+InvokeLocation invokeLocation, System.Action`1[T] action, T value) (at <3261d1d1480d44a1abe2cb945dc5a01c>:0)
Opsive.Shared.Game.SchedulerBase.Schedule[T] (System.Single delay, System.Action`1[T] action, T value) (at <3261d1d1480d44a1abe2cb945dc5a01c>:0)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.Fire (System.Single strength) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.UseItem () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.Abilities.Items.Use.LateUpdate () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateActiveAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities, System.Int32& abilityCount) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.LateUpdateUltimateLocomotion () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.UpdatePositionAndRotation () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.UpdatePositionAndRotation (System.Boolean fromAnimatorMove) (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.CharacterLocomotion.OnAnimatorMove () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnAnimatorMove () (at <6bdf56cd502b40a7ab7dc9ec10893e14>:0)

Whenever I try to shoot the Enemy this error showed up.

And also this issue is only on mobile and the error is only showing in mobile. In Unity Editor Everything is working Perfect.
 
This error happens when the item gets used? Looks like it could be an issue with the object pooler not being able to instantiate a projectile/shell object. Does this error happen when you do a PC build of the game, or only on mobile? Have you edited the folder structure of Opsive in your project at all? If so, make sure to update the assembly definition files, just in case your ShootableWeapon is losing a reference to the projectile/shell prefab for some reason.
 
This error happens when the item gets used? Looks like it could be an issue with the object pooler not being able to instantiate a projectile/shell object. Does this error happen when you do a PC build of the game, or only on mobile? Have you edited the folder structure of Opsive in your project at all? If so, make sure to update the assembly definition files, just in case your ShootableWeapon is losing a reference to the projectile/shell prefab for some reason.
Thank you for your Response I did not Build the Game for Pc I am only building it for mobile and I also did not change any folder structure in my project but can you tell how to update the assembly definition files or how can I check these files. This error happens when I try to shoot the Enemy.
 
Last edited:
I just imported some Integration packages in my project can that be the reason behind this??
The Integration packages which I imported are Control Freak and Behavior Designer.
And I am not using any shell or projectile with my Weapons.
 
Last edited:
My guess is that your prefab reference is null. You could try placing a debug statement within Traits.Die to see what it is trying to spawn.
 
My guess is that your prefab reference is null. You could try placing a debug statement within Traits.Die to see what it is trying to spawn.
Ahh... Thank you for reply I put my scenes in Behavior designer UCC Integration folder and the error is gone :). It's weird But that works for me.
 
Yeah that suggests to me that it might be an assembly definition issue as I thought... But if it's working then maybe no need to worry about it.

But in case you're interested, assembly definitions: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html You may need to create a link (using an asmdef) betwen your scenes folder and that BD/UCC integration folder, if the prefab is in that folder. If not then I have no idea why your solution would work..!
 
Top