Weapon state not being deactivated when unequipped in abilities?

DavidC

Active member
I am trying to block scroll input when a certain weapon is equipped. The weapon state has been set to Tool. I know this state is being switched on/off as the weapon is equipped/unequipped. I added the state to the "Equip Scroll" ability (blank preset). The state gets permanently set to "On" and is not following what my script indicates in the editor.

1623188796965.png
1623189408800.png


Code:
public class ToggleTool : MonoBehaviour
{
    public bool tool;

    void Start()
    {
        EventHandler.RegisterEvent<GameObject, string, bool>("OnStateChange", StateChange);
    }

    void StateChange(GameObject gObject, string state, bool isActive)
    {
        if(state == "Tool")
        {
            if(isActive)
            {
                tool = true;
            }
            else
            {
                tool = false;
            }
        }
    }

}
 
Last edited:
I see, The inspector UI does not always refresh when the OnStateChange event is called. Therefore it is possible that you're State says "(Active)" even though it isn't.
Try deselecting the character and reselecting it to force a refresh of the inspector.

There is no reason I can think of that would make the ability stop from listening to the OnStateChange event
 
Started working as expected, today. Don't know what changed, except a system reboot. I guess I have to try that more often, good ol' "turn it off and back on again." lol
 
Last edited:
Top