Movement animation

This commit is contained in:
Alexey 2025-07-27 13:25:03 +03:00
commit ab7885a3e6
4 changed files with 251 additions and 177 deletions

View file

@ -10,16 +10,19 @@ var queue_data: Dictionary = {}
@onready var camera: Camera3D = $"Camera"
@onready var weapon_player: AnimationPlayer = $"HUD/Weapon/AnimationPlayer"
@onready var movement_player: AnimationPlayer = $"MovementPlayer"
@onready var weapons: WeaponContainer = $"WeaponContainer"
# Placeholder UI
@onready var ammo_label: Label = $"HUD/Ammo"
var current_weapon:Weapon
var current_weapon: Weapon
var slot_actions: Array[StringName] = [ "slot_primary", "slot_secondary", "slot_tertiary" ]
func _ready() -> void:
movement_player.play('static')
queue.command_pushed.connect(on_queue_command_pushed)
queue.command_popped.connect(on_queue_command_popped)
queue.command_started.connect(on_queue_command_started)
@ -50,11 +53,14 @@ func _process(_delta: float) -> void:
# Slot changing logic
var slot_action = false
var slot_id = 0
for slot in slot_actions.size():
if Input.is_action_just_pressed(slot_actions[slot]):
slot_action = true
queue_data['slot_id'] = slot
if slot_action:
slot_id = slot
if slot_action and weapons.slots[slot_id].has_weapon \
and weapons.current_slot != weapons.slots[slot_id]:
queue_data['slot_id'] = slot_id
push_copied_command(CommandQueue.Command.HOLSTER_WEAPON, weapon_sides)
# Stop firing logic
@ -82,6 +88,12 @@ func _physics_process(delta: float) -> void:
target_velocity.y -= fall_acceleration * delta
velocity = target_velocity
if velocity == Vector3.ZERO and movement_player.current_animation == 'default':
movement_player.play('static')
elif movement_player.current_animation == 'static':
movement_player.play('default')
move_and_slide()
func _input(event):