From 1fba3e5bd7b010357b1b79eca4cd88c7954dc287 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 2 Apr 2022 21:51:41 +0200 Subject: [PATCH] :broom: Rename var `total_input` to `direction` --- src/entities/behaviours/PlayerMovement.gd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/entities/behaviours/PlayerMovement.gd b/src/entities/behaviours/PlayerMovement.gd index 188545f..210e7e1 100644 --- a/src/entities/behaviours/PlayerMovement.gd +++ b/src/entities/behaviours/PlayerMovement.gd @@ -8,14 +8,14 @@ onready var target: KinematicBody2D = get_parent() func _physics_process(_delta): - var total_input = Vector2.ZERO - total_input += Input.get_action_strength("player_move_up") * Vector2.UP - total_input += Input.get_action_strength("player_move_down") * Vector2.DOWN - total_input += Input.get_action_strength("player_move_left") * Vector2.LEFT - total_input += Input.get_action_strength("player_move_right") * Vector2.RIGHT + var direction = Vector2.ZERO + direction += Input.get_action_strength("player_move_up") * Vector2.UP + direction += Input.get_action_strength("player_move_down") * Vector2.DOWN + direction += Input.get_action_strength("player_move_left") * Vector2.LEFT + direction += Input.get_action_strength("player_move_right") * Vector2.RIGHT # If using a controller, allow going slower than the default speed, but not faster # Basically, "cap" movement at 1 - if total_input.length() > 1: - total_input.normalized() + if direction.length() > 1: + direction.normalized() - var _motion: Vector2 = target.move_and_slide(total_input * movement_per_second, Vector2.ZERO) + var _motion: Vector2 = target.move_and_slide(direction * movement_per_second, Vector2.ZERO)