All Questions

Community

R
Xavier Restituyo

Why won't my machine toggle?

My debugger successfully switches to 'Run' State and Displays 'Idle' in my label text when I hit 'ui-accept' again however it doesn't switch back to my 'Idle' state although both states are essentially same code with a word switched, transition to only works once.
  • The states' callback functions should be without the leading underscore. For example, unhandled_input, and not _unhandled_input. Otherwise, Godot calls the virtual _unhandled_input function on every node that defines it, so it calls it on all of your states one after the other.

  • R
    Xavier Restituyo

    I was able to toggle between run and idle only by switching

     if event.is_action_pressed("ui_accept"):...
    

    on run state to

    if event.is_action_released("ui-accept")....
    

    If both the Idle and Run state scripts have the same keystroke for

    _unhandled_input()

    callback toggle

    hasn't transition between my states, different actions work fine and correctly change my state. Do you know why this could be?


  • I can't know like that, there's certainly a line of code that's incorrect. If you need me to look at it, could you upload the project as a .zip archive and link to it here?