Full controle tactile et souris
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user