Skip to content

Single-fire reliable events #189

Closed Answered by elementbound
bryanmylee asked this question in Q&A
Discussion options

You must be logged in to vote

This is caused by the custom tick loop. From the Input docs:

Returns true when the user has started pressing the action event in the current frame or physics tick.

What happens is between pressing the button, a frame might pass before the tick loop runs next. Imagine a timeline like this:

  1. _process
  2. Input is pressed
  3. _process <- is_action_just_pressed is true
  4. _process <- is_action_just_pressed is false
  5. NetworkTime.on_tick <- is_action_just_pressed is false
  6. _process <- is_action_just_pressed is false

You can move your input to a separate variable on your class, gather input on every frame, use the gathered input in the first tick in the loop, then reset the input. Something like this:

var 

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@bryanmylee
Comment options

Answer selected by elementbound
Comment options

You must be logged in to vote
1 reply
@elementbound
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants