Full controle tactile et souris

This commit is contained in:
Thomas
2025-03-29 11:34:41 +01:00
parent be1ef5d71c
commit 2125236638
8 changed files with 81 additions and 84 deletions

View File

@@ -4,6 +4,7 @@ extends Node2D
@export var ray : ShapeCast2D
var can_interact_with : Node2D
@onready var world: World = get_parent().get_parent();
@onready var pathFinder : HumanPathFinder = $"../PathFinder"
var possible_interactables : Array[Node2D]
@@ -19,11 +20,12 @@ func _unhandled_input(event: InputEvent) -> void:
human.wants_to_interact_with = can_interact_with
else:
human.wants_to_grab = true
# moving using either touch or mouse button
if event is InputEventMouseButton or event is InputEventScreenTouch:
var tile_pos = world.local_to_map(world.to_local(get_global_mouse_position()))
if event.pressed:
print(event.position, tile_pos)
$"../PathFinder".destination = get_global_mouse_position()
pathFinder.destination = get_global_mouse_position()
func _process(delta) -> void:
ray.target_position = human.last_facing_direction * 48
@@ -77,4 +79,4 @@ func _process(delta) -> void:
if can_interact_with != closest:
can_interact_with = closest
if can_interact_with:
can_interact_with.enable_interaction_clue()
can_interact_with.enable_interaction_clue(human)