pera
pera

Reputation: 982

How to animate model that has all animations in one action?

I have older animated models that have keyframe animation meaning all animations (idle, walk, attack) are in one action. I tried splitting this in multiple actions in Blender but I cant make it work (I am not 3D designer). So my question is how to use new animation system to play only part of the action (eg. from keyframe 25 to 50) and then smoothly switch to next animation (from keyframe 50 to 75).

I have something like this for start:

MONSTER_ANIMATION_ALL = monster.animations[0];
action = mixer.clipAction(MONSTER_ANIMATION_ALL);
action.enabled = true;
action.setEffectiveTimeScale( 1 );
action.setEffectiveWeight( 1);
action.time = 0;
action.play();

Upvotes: 2

Views: 615

Answers (1)

Mugen87
Mugen87

Reputation: 31026

You can actually split your single animation clip into multiple ones via AnimationUtils.subclip(). From the documentation:

Creates a new clip, containing only the segment of the original clip between the given frames.

So the only thing you need to know are the start and end frames for each animation. When you have an animation clip per animation, it's possible to perform smooth transitions by using the interface of AnimationAction. Meaning fadeIn/fadeOut or crossfade.

Upvotes: 3

Related Questions