Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends AnimatedSprite2D
- class_name PlayerAnims
- func trigger_animation(velocity: Vector2, direction: int):
- if not get_parent().is_on_floor():
- play("jump")
- elif Input.is_action_just_released("jump"):
- play("fall")
- # Handle slide animations
- elif sign(velocity.x) != sign(direction) && velocity.x != 0 && direction != 0:
- play("damp")
- scale.x = direction
- else:
- # Handle sprite direction
- if scale.x == 1 && sign(velocity.x) == -1:
- scale.x = -1
- elif scale.x == -1 && sign(velocity.x) == 1:
- scale.x = 1
- # Handle run and idle animations
- if velocity.x != 0:
- play("walk")
- elif velocity.x < 1 && not Input.is_action_just_pressed("jump") && HealthManager.current_health > 0:
- play("idle")
- # Handle death animation
- if HealthManager.current_health <= 0:
- play("death")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement