This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Access state variable in _input()?

ZingZing Posts: 45Member

The state variable comes from _integrate_forces(state), which is usually fine. However, I need my movement function to move the exact frame that the user hits the movement buttons. How can I use the state variable in _input?


Tags :

Best Answer

  • cyberealitycybereality Posts: 928
    Accepted Answer

    I believe you can just save state into your own variable for use elsewhere.

    At the top of your script:

    var last_state
    

    At the integrate forces:

    func _integrate_forces(state):
        last_state = state
    

    In input:

    func _input(event):
        # do something with last_state
    

Answers

  • cyberealitycybereality Posts: 928Moderator
    Accepted Answer

    I believe you can just save state into your own variable for use elsewhere.

    At the top of your script:

    var last_state
    

    At the integrate forces:

    func _integrate_forces(state):
        last_state = state
    

    In input:

    func _input(event):
        # do something with last_state
    
Sign In or Register to comment.