Can't fire weapon after equipping....

rod.hope

New member
I have created a character, some weapons and pickups. One of the weapons added generates the following error when i try to fire it - I believe it has something to do with the items ability but no matter how i configure it, i get the same errors. The character and the other weapon all work great, all of the pickups work, i can cycle through the weapons, i can see that the weapon and its ammo are in my inventory. any idea what specifically would cause this?



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

Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.CanUseItem (Opsive.UltimateCharacterController.Character.Abilities.Items.ItemAbility itemAbility, UseAbilityState abilityState) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:541)

Opsive.UltimateCharacterController.Character.Abilities.Items.Use.CanStartAbility () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/Use.cs:241)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Items.ItemAbility itemAbility, Boolean ignoreCanStartCheck) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1022)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, Boolean ignorePriority, Boolean ignoreCanStartCheck) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:880)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, Boolean ignorePriority) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:866)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:855)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:233)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:121)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:87)

Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:73)
 
If you can set a breakpoint on Line 541 and tell me what is null I should have a better idea, but my bet is that m_ShootableWeaponPerspectiveProperties is null. This will be null if your item doesn't have a First/ThirdPersonShootableWeaponProperties component added to it. This component should automatically be added during the item manager setup though.
 
tried setting the breakpoint but seems to crash my unity (it goes unresponsive until i end debugging). there is a 'ThirdPersonShootableWeaponProperties' component on my weapon though.
 
When i try to shoot this weapon it never even makes it into the ' CanUseItem ' logic (i put some debug.log in there) i see the trace when i shoot the other weapon.
 
tried setting the breakpoint but seems to crash my unity (it goes unresponsive until i end debugging). there is a 'ThirdPersonShootableWeaponProperties' component on my weapon though.
It doesn't make it to ThirdPersonShootableWeaponProperties.CanUseItem, correct?

If you aren't changing perspectives the m_ShootableWeaponPerspectiveProperties assignment is within Start - can you debug this to see if it's assigning the value properly? What would also be extremely useful is if you could list the steps to reproduce from a fresh project so I can take a closer look at it.
 
yeah - it's weird that it doesn't get there but putting a breakpoint freezes me.


protected override void Start()
{
base.Start();
Debug.Log("start");
if (m_ShootableWeaponPerspectiveProperties == null) {
Debug.Log("this is null");
m_ShootableWeaponPerspectiveProperties = m_ActivePerspectiveProperties as IShootableWeaponPerspectiveProperties;
}
}

when i pick up the problem weapon i do see 'this is null' traced - doesn't happen on the other one, hmmmm. in the inspector they have the same components attached only difference being this one (the problem one) also has the melee script.

steps: pretty simple scene.

1) added a character (third person adventure).
2) created the itemCollection.
3) added some item types to the collection (1 pistol, 1 assault rifle)
4) added the item types to the character with the character manager.
5) created some pickups to add the items to the character.
 
Can you upload a repro scene so I can take a look? If your using the assets included in the controller then I should only need the scene and the item collection (with metadata file).
 
something else.... if i change the problem weapons actionID to 1 (currently it's 0) the weapon seems to enter the CanUseItem logic and returns true. The weapon seems to aim now (and i get the proper crosshair in the UI) but still doesn't fire. Also no more console errors. unfortunately this takes away my ability to toggle weapons.
i'm a bit confused by the 'item abilities' inspector - i have tried matching up the input numbers and adding a new 'use' ability, but it doesn't seem to have an affect.
 
ActionID of 0 is correct since you only have one action added to the item (the ShootableWeapon). You should only have one Use ability to test things out - multiple uses are for the grenade/melee attack in the demo scenes. If you want to email me your project I can take a closer look since I'm not really sure what is going on.
 
hey i will try to figure out the best way to package this up with the least amount of kilobytes :)
will most likely put it on my FTP for you. Thanks for all the help, i really appreciate it!
 
Justin solved over email - this was the problem.


Justin Said:

There we go.

The reason you are getting that error is because the ActionID is set to 1 on the ThirdPersonShootableWeaponProperties. This ID must match the action that it applies to, the ShootableWeapon:


I can add a warning in the editor if the action component doesn't match any property ids. The weapon won't fire immediately but that is then related to the third item under the fire troubleshooting section:

https://opsive.com/support/document...roller/items/actions/usable/shootable-weapon/
 

Attachments

  • image.png
    image.png
    40.6 KB · Views: 27
Top