Godot Version
4.2.2
Question
still very new to godot. I have the left and right movement based on events working, however i am trying to detect if both inputs have been registered and i ran into an issue where event.is_pressed() is saying false when is pressed and true when it is. help.
var where_touching : Vector3
#temp
var is_touching : bool
func _ready():
Input.set_use_accumulated_input(true)
func _unhandled_input(event):
if event is InputEventScreenTouch or event is InputEventScreenDrag:
handle_input(event.position)
if event.is_pressed() or event is InputEventScreenDrag:
is_touching = true
else:
is_touching = false
func handle_input(touch_pos):
var viewport_size = get_viewport().size
var screen_middle = viewport_size.x * SCREEN_DIVIDER
if touch_pos.x < screen_middle and not touch_pos.x > screen_middle :
handle_left_side_input(touch_pos)
where_touching.x = 1
elif touch_pos.x > screen_middle and not touch_pos.x < screen_middle :
handle_right_side_input(touch_pos)
where_touching.y = 1
else:
where_touching = Vector3(0,0,0)
Global.diag = where_touching
func handle_left_side_input(touch_pos):
# Implement your left side input logic here
direction = -1
print("left " + str(is_touching))
func handle_right_side_input(touch_pos):
# Implement your right side input logic here
direction = 1
print("right " + str(is_touching))
func handle_both_side_input(touch_pos):
print(“both sides”)