Skip to content

Commit 84e9842

Browse files
committed
CharacterSpriteBehavior: Fallback to idle when walk is not available
When the SpriteFrames animation doesn't have an animation named "walk", use its "idle" animation for walking. This makes the modding easier, since a single animation is now needed for start testing a SpriteFrames in a character with any of the walk behaviors. We also use "idle" at double speed for running. And also, when a character is made of multiple parts, some parts can stay in the "idle" animation. Meaning there are less parts to draw.
1 parent bc625a2 commit 84e9842

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scenes/game_logic/sprite_behaviors/character_sprite_behavior.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ func _process_animations(_delta: float) -> void:
5656
sprite.play(&"run")
5757
else:
5858
sprite.speed_scale = 2.0
59-
sprite.play(&"walk")
59+
sprite.play(&"walk" if sprite.sprite_frames.has_animation(&"walk") else &"idle")
6060
else:
6161
sprite.speed_scale = 1.0
62-
sprite.play(&"walk")
62+
sprite.play(&"walk" if sprite.sprite_frames.has_animation(&"walk") else &"idle")
6363

6464

6565
func _notification(what: int) -> void:

0 commit comments

Comments
 (0)