mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-24 21:54:18 +00:00
🧹 Rename var total_input
to direction
This commit is contained in:
parent
a5aafc99b4
commit
1fba3e5bd7
1 changed files with 8 additions and 8 deletions
|
@ -8,14 +8,14 @@ onready var target: KinematicBody2D = get_parent()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
var total_input = Vector2.ZERO
|
var direction = Vector2.ZERO
|
||||||
total_input += Input.get_action_strength("player_move_up") * Vector2.UP
|
direction += Input.get_action_strength("player_move_up") * Vector2.UP
|
||||||
total_input += Input.get_action_strength("player_move_down") * Vector2.DOWN
|
direction += Input.get_action_strength("player_move_down") * Vector2.DOWN
|
||||||
total_input += Input.get_action_strength("player_move_left") * Vector2.LEFT
|
direction += Input.get_action_strength("player_move_left") * Vector2.LEFT
|
||||||
total_input += Input.get_action_strength("player_move_right") * Vector2.RIGHT
|
direction += Input.get_action_strength("player_move_right") * Vector2.RIGHT
|
||||||
# If using a controller, allow going slower than the default speed, but not faster
|
# If using a controller, allow going slower than the default speed, but not faster
|
||||||
# Basically, "cap" movement at 1
|
# Basically, "cap" movement at 1
|
||||||
if total_input.length() > 1:
|
if direction.length() > 1:
|
||||||
total_input.normalized()
|
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)
|
||||||
|
|
Loading…
Reference in a new issue