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: 927
    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: 927Moderator
    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.