Multiple animation for a Third persom controller

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By satou

So here is a quick question that I need for my project.

How do I approach having multiple animation for multiple weapon. What I mean is that I want for example a sword weapon which has different idle animation, run, and attack and for example I would want a gun as another weapon which has different set of animations. How can I do it so that when equipping the sword I have the sword animations and when equipping the gun I have the gun animations?

I work in 3D by the way

:bust_in_silhouette: Reply From: spaceyjase

Typically a developer would use a animation tree (and a combination of blend spaces, etc):

For example, a rudimentary state machine might look like this:

State Machine

Where Idle and Idle_Long have different animations depending on game state; here, they could be your sword and gun idle states. You may even have the same animation and just swap the model into place (“This is the way”) using a bone attachment node.

How you implement this is really dependent on your game.

can he swap the animationplayer in the animationtree when he change weapon ?

purple_mage | 2023-03-29 16:21

Yes, the tree will reference an animation player and each state is a specific animation (and can reference other trees and states; it can get very complicated!). Ideally this is controlled via script with a reference to the animation tree (or states), changing their properties accordingly (see the documentation link).

The example project is worth checking out too: Third Person Shooter Demo - Godot Asset Library

spaceyjase | 2023-03-29 16:25