Object doesn't seem to be checking if a button is being held when spawned

Hey all, I have an object that is spawned and needs to check if a button is currently being pressed, but it doesn’t seem to be working.

Here is the simple code I have:

void Update()
    {
        if (Input.GetButtonDown("Rewind"))
        {
            StartRewind();
        }
        if (Input.GetButtonUp("Rewind"))
        {
            StopRewind();
        }
        if (Input.GetButtonDown("Pause"))
        {
            StartPause();
        }
        if (Input.GetButtonUp("Pause"))
        {
            StopPause();
        }
    }

However, if I have the “Pause” button held and then spawn the object, it doesn’t seem to check for the button being held down. Any ideas?

I even tried putting some Debug.Logs in the If (Input.GetButtonDown(“Pause”) and it does not show the debug

void Update()
    {
        if (Input.GetButtonDown("Pause"))
        {
            if (isSpawned)
            {
                Debug.Log("Update");
            }
            StartPause();
        }
    }

the debug does not fire

Break apart gathering of the intention (key up/ key down) into boolean variables so you can easily print them out.

Then use those boolean variables to kick off what you want to do, perhaps alongside Debug.Log() statements.

If you can’t get them all working at once, comment them out and try them one at a time.

1 Like

I think I got it to work, I was checking Input.GetButtonDown which only checks for when the button is first presssed, but it seems that Input.GetButton will check if it is currently being held, so it seems to work for now!