0

I'm using Invoke Unity Events to detect whether a user presses or holds a button. I can see the function firing, and I'm setting respawnHeld to true. Yet Update always logs it as false. I'm completely at a loss here....I can't see what could possibly be setting respawnHeld back to false.

    private bool respawnHeld;

    // Update is called once per frame
    void Update()
    {
        Debug.Log($"In Update Function RespawnHeld is {respawnHeld}");
    }

    public void RespawnInput(InputAction.CallbackContext callbackContext)
    {
        Debug.Log("SETTING RESPAWN HELD TO TRUE");
        respawnHeld = true;
        Debug.Log($"In RespawnInput Function RespawnHeld is {respawnHeld}");
    }

After pressing my key 'R'. I would expect to see logs stating "In Update Function RespawnHeld is True". However the logs I'm getting are as follows:

enter image description here

Any help would be hugely appreciated!

2

1 Answer 1

1

Unfortunately I can't say with certainty what fixed this. But in my case the caller of Respawn Input is a Unity Event (from the input system). I removed the script from my Game Object, then reconfigured all my events and it works now. enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.