# class variables
@export_category("Movement")
-@export var _walk_speed := 5.0
+@export var _walk_speed := 4.0
@export var _jump_speed := 9.0
@export var _fall_speed := 2.0
-@export var _locked_z := true
@export_category("Camera")
@export var _camera_distance := 5.0
if velocity.y > 0:
velocity.y = 0
elif event.is_action_pressed("player-attack"):
- _skin.attack()
+ if Input.is_action_pressed("player-up"):
+ _skin.attack_up()
+ _last_movement_direction = Vector3.FORWARD
+ elif Input.is_action_pressed("player-down") and not is_on_floor():
+ _skin.attack_down()
+ _last_movement_direction = Vector3.FORWARD
+ else:
+ _skin.attack_neutral()
+ elif event.is_action_pressed("player-up"):
+ _last_movement_direction = Vector3.FORWARD
func _physics_process(delta: float) -> void:
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("player-left", "player-right", "player-up", "player-down")
- var direction := -(transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
+ var direction := -(transform.basis * Vector3(input_dir.x, input_dir.y, 0)).normalized()
- if direction:
+ _skin.head_tilt(direction.y)
+
+ if direction.x:
velocity.x = direction.x * _walk_speed
- if not _locked_z:
- velocity.z = direction.z * _walk_speed
_last_movement_direction = direction
else:
velocity.x = 0
- velocity.z = 0
func _process_player_skin(_delta: float) -> void:
- _skin.global_rotation.y = Vector3.BACK.signed_angle_to(_last_movement_direction, Vector3.UP)
-
+ _skin.global_rotation.y = Vector3.BACK.signed_angle_to(_last_movement_direction - Vector3.BACK, Vector3.UP)
if is_on_floor():
_skin.move(velocity.length())
else: