diff options
-rw-r--r-- | client/scripts/controllable_player.gd | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/client/scripts/controllable_player.gd b/client/scripts/controllable_player.gd index 12925f60..91b786c5 100644 --- a/client/scripts/controllable_player.gd +++ b/client/scripts/controllable_player.gd @@ -7,6 +7,8 @@ const PLAYER_SPEED: float = 25.; var facing = Vector2(1, 0) var velocity_ = Vector2(0, 0) +var target: Vector2i = Vector2i(0, 0) + func _ready(): var timer = Timer.new() timer.one_shot = false @@ -22,10 +24,14 @@ func _process(delta): input = input.rotated(-game.camera.angle_target) position_anim = position_ rotation_anim = rotation_ - if not Input.is_action_pressed("interact")||Input.is_action_just_pressed("interact"): - interact() - else: + if Input.is_action_pressed("interact") or Input.is_action_just_released("interact"): input *= 0 + else: + target = Vector2i( + int(floor(position.x + sin(rotation.y))), + int(floor(position.z + cos(rotation.y))) + ) + interact() update(delta, input) super(delta) @@ -73,10 +79,6 @@ func update_position(new_position: Vector2, _new_rotation: float): position_ = new_position func interact(): - var target = Vector2i( - int(floor(position.x + sin(rotation.y))), - int(floor(position.z + cos(rotation.y))) - ) var tile_idx = str(target) var t: Floor = game.map.tile_by_pos.get(tile_idx) if t != null: |