]> Untitled Git - knight.git/blobdiff - player/player.gd
Updated project name
[knight.git] / player / player.gd
index eae307ec63c8a8d09c9eb4aeda52ba04a195989a..6099c08953ca721801f81b09e405f5357077dfd1 100644 (file)
@@ -3,10 +3,9 @@ class_name Player extends CharacterBody3D
 
 # 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
@@ -34,7 +33,16 @@ func _input(event: InputEvent) -> void:
                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:
@@ -57,21 +65,19 @@ func _process_player_input(_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: