tochie-kit/nodes/singletons/InputUtils.gd

14 lines
406 B
GDScript

extends Node
func input_event_to_4way_direction(p_event: InputEvent) -> Vector2:
var result := Vector2.ZERO
if p_event.is_action_pressed("move_down"):
result.y += 1
if p_event.is_action_pressed("move_right"):
result.x += 1
if p_event.is_action_pressed("move_up"):
result.y -= 1
if p_event.is_action_pressed("move_left"):
result.x -= 1
return result