UCC + UIS Integration Issue

Shanmukh

Member
when equipping a weapon it consumes bullets, size of weapon clip. but they don't load into the weapon. if I click reload, it consumes again bullets. this time bullets are reloaded into the weapon.
 
Last edited:
I've run into similar issue when doing integrations after setting players up.
It's like the database loses it's reference to the ammo.
 
Are you using the AmmoData attribute? Did you bind the AmmoData Attribute to the weapon using the ShootableWeaponAmmoBinding script?
Could you share some screen shots of your item prefab and the AmmoData Attribute?
And maybe a video showcasing the problem could help.
 
I am using AmmoData and bind the AmmoData Attribute to the weapon.
please watch the video.
in the video first, take a gun with 60 ammo. when picking up it consumes 48 bullets. but not loading into the gun.
the second one I unequip the previous gun and equip the next gun with ammo 50. again the same problem. it shows 2 bullets. it consumes 48 bullets.
I equip the next gun with out unequip, I didn't get the problem
uis issue.JPG
 
Ok my guess is that something is messing up the execution order.
The AmmoData must be bound to the Item before the item reloads, otherwise the ammo on the weapon is overridden by the ammo in the attribute.
Could you double check your scripts Execution order in the settings:
1619509127961.png

If that's not it, could you add a Debug.Log in the
ShootableWeaponAmmoBinding script in the SetItem function
And another Debug.Log in the
ShootableWeapon script in the ReloadItem function

The Binding should be done before the reload. The logs might help me identify why that's not the case.

Just to be clear does it work in the Demo scene that comes with the integration?
 
1. execution order is the same in the image.
2. i get the first log from the ShootableWeapon script. the second one from ShootableWeaponAmmoBinding script.
3. Demo scene working perfectly. I didn't see the issue on the Demo scene.
 
Could you share the full logs. It should help me identify why the shootable Weapon script happens before the shootable weapon ammo binding script. It should be the other way around.
I might have missed a special use case, once we identify the problem I'll fix it.
 
I didn't get any other logs from UIS. except those, which I created for execution order.
 
Last edited:
Yes I know, those logs you created are the ones I would like to see.
It will help me see the execution flow and identify where it diverges from the demo scene.
 
uis issue.JPG

Log from ShootableWeapon script
UnityEngine.Debug:Log (object)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon:ReloadItem (bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:1567)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon:WillEquip () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:485)
Opsive.UltimateCharacterController.Items.Item:WillEquip () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Item.cs:434)
Opsive.UltimateCharacterController.Character.Abilities.Items.EquipUnequip:InvokeWillEquipItem (Opsive.UltimateCharacterController.Items.Item,int) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/EquipUnequip.cs:257)
Opsive.UltimateCharacterController.Character.Abilities.Items.EquipUnequip:Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/EquipUnequip.cs:634)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:UpdateAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[]) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:794)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:UpdateUltimateLocomotion () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:725)
Opsive.UltimateCharacterController.Character.CharacterLocomotion:Move (single,single,single) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/CharacterLocomotion.cs:477)
Opsive.UltimateCharacterController.Game.KinematicObjectManager/KinematicCharacter:Move (bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:237)
Opsive.UltimateCharacterController.Game.KinematicObjectManager:Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/KinematicObjectManager.cs:841)



Log from ShootableWeaponAmmoBinding script
UnityEngine.Debug:Log (object)
ShootableWeaponAmmoBinding:SetItem () (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/ItemBindings/ShootableWeaponAmmoBinding.cs:118)
ShootableWeaponAmmoBinding:SetItemObject (Opsive.UltimateInventorySystem.Core.ItemObject) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/ItemBindings/ShootableWeaponAmmoBinding.cs:113)
ShootableWeaponAmmoBinding:Start () (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/ItemBindings/ShootableWeaponAmmoBinding.cs:93)
 
I was able to replicate the bug thanks to your logs. The difference was that I'm updating the character on Fixed Update while you are updating it on Update.

1619597209605.png

The issue is that the ShootableWeaponAmmo Binding doesn't listen to the changes until its start function so I moved a everything that was in start to awake and now it should also work with Update

So in ShootableWeaponAmmoBinding remove the start function and replace the Awake by this:
Code:
void Awake()
{
    if (m_ShootableWeapon == null) {
        m_ShootableWeapon = GetComponent<ShootableWeapon>();
    }
    m_AmmoDataAttributeBinding = new AttributeBinding<AmmoData>(m_AmmoDataAttributeName, this, "AmmoData");
    m_AmmoDataAttributeBinding.CreatePropertyDelegates();
    
    if (m_ItemObject != null) { return; }
    var itemObject = GetComponent<ItemObject>();
    if (itemObject != null) {
        SetItemObject(itemObject);
    }
}

Let me know if this fixes your issue
 
Top