le player se pilote à la souris ou avec le doigt

reste à faire: intérargir avec bob
This commit is contained in:
Thomas
2025-03-28 19:08:24 +01:00
parent 7a58999034
commit be1ef5d71c
12 changed files with 207 additions and 67 deletions

View File

@@ -1,8 +1,9 @@
extends Node
extends Node2D
@export var human: Human
@export var ray : ShapeCast2D
var can_interact_with : Node2D
@onready var world: World = get_parent().get_parent();
var possible_interactables : Array[Node2D]
@@ -18,6 +19,11 @@ func _unhandled_input(event: InputEvent) -> void:
human.wants_to_interact_with = can_interact_with
else:
human.wants_to_grab = true
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()
func _process(delta) -> void:
ray.target_position = human.last_facing_direction * 48