add side switching animation

This commit is contained in:
2025-02-25 03:51:12 +10:00
parent 58983ecda2
commit 2633390dd8
8 changed files with 333 additions and 178 deletions

View File

@@ -20,8 +20,7 @@ func _ready() -> void:
func _process(_delta: float) -> void:
aiming.controller_aiming(movement.move_input)
call_deferred("_mouse_aiming")
call_deferred("_aiming")
_process_respawning()
var aim_pos := global_position + aiming.aim_offset
@@ -39,9 +38,13 @@ func _physics_process(delta: float) -> void:
move_and_slide()
func _mouse_aiming() -> void:
func _aiming() -> void:
aiming.controller_aiming(movement.move_input)
var mouse_pos := get_viewport().get_mouse_position()
aiming.mouse_aiming(mouse_pos, global_position, is_on_floor())
if attack.is_hitting():
return
if aiming.aim_offset.length() > 0:
look_at(global_position + aiming.aim_offset, Vector3.UP, true)

View File

@@ -0,0 +1,25 @@
extends AnimationTree
const SUFFIX_LEFT := "_L"
const SUFFIX_RIGHT := "_R"
@export var player: Player
func _ready() -> void:
assert(player, "player missing!")
func _process(_delta: float) -> void:
set(&"parameters/StateMachine/conditions/side_L", _is_left())
set(&"parameters/StateMachine/conditions/side_R", not _is_left())
func _is_left() -> bool:
return player.attack.side == PlayerAttack.Side.LEFT
func _suffix(invert: bool) -> String:
if not invert:
return SUFFIX_LEFT if _is_left() else SUFFIX_RIGHT
return SUFFIX_LEFT if not _is_left() else SUFFIX_RIGHT

View File

@@ -19,7 +19,7 @@ enum Side { RIGHT, LEFT }
@export var _hit_projectile_speed: float = 35
@export var _direction_angles: Dictionary = {-PI / 6: 0, PI / 6: PI / 4, PI: PI / 2}
var _side := Side.RIGHT
var side := Side.RIGHT
var _debug_collision_shapes := DebugCollisionShapes.new()
@@ -103,7 +103,7 @@ func _physics_process(_delta: float) -> void:
func is_hitting() -> bool:
return _hit_window_timer > 0
return _cooldown_timer > 0
func _attack() -> void:
@@ -115,7 +115,7 @@ func _attack() -> void:
_hit_window_timer = _hit_window_time
_swoop_effect_timer = _swoop_effect_time
_debug_collision_shapes.set_visibility(true)
_side = Side.LEFT if _side == Side.RIGHT else Side.RIGHT
side = Side.LEFT if side == Side.RIGHT else Side.RIGHT
func _hit_projectile(projectile: Projectile) -> void:
@@ -128,10 +128,10 @@ func _hit_projectile(projectile: Projectile) -> void:
if angle > _attack_max_angle or angle < -_attack_max_angle:
return
var angle_sign := 1.0 if _side == Side.RIGHT else -1.0
var angle_sign := -1.0 if side == Side.RIGHT else 1.0
var angle_signed := angle * angle_sign
Debugger.text("side", Side.find_key(_side), 2)
Debugger.text("side", Side.find_key(side), 2)
Debugger.text("angle_signed", rad_to_deg(angle_signed), 2)
var prev_dir_angle: float = -_attack_max_angle