You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wondering, since the method signature is _is_action_press_buffered(action), shouldn't this script only care about events that are assigned to actions in the InputMap? And if so, couldn't you get rid of most of the conditional logic in the keycode checking etc? So it could all be simplified to a dictionary of action names?
Something like this
extends Node
const BUFFER_WINDOW: int = 150
var buffer: Dictionary = {}
func _input(event: InputEvent) -> void:
var action: StringName = _get_event_action(event)
if action:
buffer[action] = Time.get_ticks_msec()
func is_action_pressed_buffered(action: StringName) -> bool:
if buffer.has(action):
return Time.get_ticks_msec() - buffer[action] <= BUFFER_WINDOW
return false
func _get_event_action(event: InputEvent) -> StringName:
var actions: Array[StringName] = InputMap.get_actions()
var event_action: StringName
actions.reverse()
for action in actions:
if !event_action && event.is_action(action):
event_action = action
return event_action
The text was updated successfully, but these errors were encountered:
Just wondering, since the method signature is
_is_action_press_buffered(action)
, shouldn't this script only care about events that are assigned to actions in theInputMap
? And if so, couldn't you get rid of most of the conditional logic in the keycode checking etc? So it could all be simplified to a dictionary of action names?Something like this
The text was updated successfully, but these errors were encountered: