2h, Shield visibility and Dual-Handed Weapons

It’s possible, but… far more complicated than I’m willing to go. Sort of a line in the sand at this point.

I’m working on some adjustments to make the simpler dual wield more robust (parameterized hits, effects from each weapon, returning (Weapon, Weapon) from Spawn, etc.

1 Like

I won’t judge then, anything for now is better than nothing. Thanks for taking the time to help me out Brian :slight_smile:

At the very least, can we make them two seperate objects?

OK umm… on the side, as we try develop the Dual-Hand Weapons system, when creating the 2h system, I think there’s an Edge case we missed out on. For some reason, if the shield when we start the game is the absolutely first thing we wield, I get this NRE:

NullReferenceException: Object reference not set to an instance of an object
GameDevTV.UI.Inventories.InventorySlotUI.TryEquipShield (RPG.Combat.ShieldConfig shield) (at Assets/GameDev.tv Assets/Scripts/UI/Inventories/InventorySlotUI.cs:341)
GameDevTV.UI.Inventories.InventorySlotUI.TryHandleRightClick () (at Assets/GameDev.tv Assets/Scripts/UI/Inventories/InventorySlotUI.cs:120)
UnityEngine.Events.InvokableCall.Invoke () (at <ba783288ca164d3099898a8819fcec1c>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <ba783288ca164d3099898a8819fcec1c>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:514)

However, if it’s the second item we try wielding onwards, it works perfectly fine. Any ideas where did we mess this up?

Is it this line, by chance? (Hint: I have no idea what specific line numbers correspond to what lines, so it can be helpful with an NRE to post the method where the error was (TryEquipShield) and mark the line number with the error (341, but I don’t know which one that is). When posting an NRE, it’s best to do that to speed things up.

if (otherWeapon!=null && otherWeapon.IsLeftHanded || otherWeapon.IsTwoHanded) //by definition, if this is true then we have space and can swap

If this is the line, try it this way:

if (otherWeapon!=null && (otherWeapon.IsLeftHanded || otherWeapon.IsTwoHanded)) //by definition, if this is true then we have space and can swap

I believe it was that line, apologies for forgetting to update the line numbers. I’m currently not at home so we’ll check on that solution in an hour or 2

Yup, that fixed. Thanks again Brian

Whenever you have the dual hand system ready, please keep me updated. I’m also trying it from my side, but it’s… hard tbh. I’d love to see what you come up with :slight_smile:

Privacy & Terms