Skip to content

Add walk animation to townies#2145

Merged
manuq merged 4 commits intomainfrom
walking-townies
Apr 28, 2026
Merged

Add walk animation to townies#2145
manuq merged 4 commits intomainfrom
walking-townies

Conversation

@manuq
Copy link
Copy Markdown
Collaborator

@manuq manuq commented Apr 27, 2026

RandomTextureSpriteBehavior: Allow idle + walk animation

Assets:

  • Rename existing part assets to "idle".
  • Add walk animation for the legs part.

RandomTextureSpriteBehavior:

  • Export an Array of SpriteFrames resources. Instead of using the custom addon
    to change the textures.

Townie scene:

  • Add a CharacterSpriteBehavior to each part. And configure the legs part with
    the new animations.

  • Add one .tres file per body part variant. And configure each Array of
    SpriteFrames resources with them.

Townie demo:

  • Add a FollowWalkBehavior to one townie, and remove the TalkBehavior.

CharacterSpriteBehavior: Reset frames when back to idle

The townies "idle" has a subtle up and down animation.

For a character made of parts, since the last commit one part (like the head)
may keep playing "idle" while another (like the legs) may play "walk". But when
the character is back to idle, all parts should be set in sync again. Otherwise,
the head may go up when the legs go down, making a funny but not desired (for
now) dance.

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.

manuq added 3 commits April 27, 2026 18:37
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.
The townies "idle" has a subtle up and down animation.

For a character made of parts, since the last commit one part (like the head)
may keep playing "idle" while another (like the legs) may play "walk". But when
the character is back to idle, all parts should be set in sync again. Otherwise,
the head may go up when the legs go down, making a funny but not desired (for
now) dance.
Assets:

- Rename existing part assets to "idle".
- Add walk animation for the legs part.

RandomTextureSpriteBehavior:

- Export an Array of SpriteFrames resources. Instead of using the custom addon
  to change the textures.

Townie scene:

- Add a CharacterSpriteBehavior to each part. And configure the legs part with
  the new animations.

- Add one .tres file per body part variant. And configure each Array of
  SpriteFrames resources with them.

Townie demo:

- Add a FollowWalkBehavior to one townie, and remove the TalkBehavior.
@manuq manuq requested a review from a team as a code owner April 27, 2026 21:41
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Test build no longer available.

@manuq
Copy link
Copy Markdown
Collaborator Author

manuq commented Apr 27, 2026

recording.webm

And this is the funny bug I've been fighting today live on Discord:

Grabacion.de.pantalla.desde.2026-04-27.18-47-25.mp4

The lower part of the body is out of sync after a walk. This was fixed by resetting frame and progress of all animations when back to idle (either if they are reusing the idle animation when walking or not):

sprite.set_frame_and_progress(0, 0.0)

@manuq
Copy link
Copy Markdown
Collaborator Author

manuq commented Apr 28, 2026

If I find time today/tomorrow I will also animate the body and hair (skipping the faces) for the walk cycle.

Copy link
Copy Markdown
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Having walking animations for townies will make it much easier to make the world feel alive.

sprite.sprite_frames = new_sprite_frames
if not Engine.is_editor_hint():
if previous_animation in sprite.sprite_frames.get_animation_names():
sprite.play(&"idle")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be re-playing previous_animation? If not I don't quite understand what the previous_animation check is for.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this should be the previous_animation

@manuq manuq merged commit 754e68e into main Apr 28, 2026
5 checks passed
@manuq manuq deleted the walking-townies branch April 28, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants