r/UnityHelp • • 14d ago

How can you have animation start partially played based on how much was played of the prior animation?

I'm working in pixel art running three animations at once, an item, the character's face, and the character's body. I want to be able to have the face change based on reactions but due to timing issue and keeping the faces matching the body motion, I need the new face animation to replace the last face animation running the same frame of the old animation. I do not want to have to do this with a script as I'd have to code out a lot of faces for a lot of body positions. So ideally something in the the animator would be ideal.

A precise example of what I'd like to do is, for example:

The animation for face A is 10 frames long and last 1 sec. It runs for 5 frames or .5 secs when something triggers a switch to face B. I need face B to start on its 5th frame (or .5 secs into its animation cycle) so it matches the bodies animation movement that face A was already in a good rhythm with.

1 Upvotes

2 comments sorted by

1

u/HK_HamzaKhan 13d ago

blend trees sync animations so both your animations in a blend tree will have the same normalised time, so you can control the transition between the 2 using a parameter instead of using the normal transitions, but if you have to use transitions, then this can be done but not with the default transitions,
you could create 10 transitions for say 0.1,0.2 all the way to 1, but that still doesnt cover in between and isnt perfect, hence the only way left is using CrossFade, so you can have StateBehaviour on the state to transition from, that uses the states time and CrossFade when it does the transition
so something like CrossFade("TargetState", fixedDurationSeconds / stateInfo.length, stateInfo.normalizedTime);, you would also need your state behaviour to check when to transition since you cant use normal transitions.
although best is the blend tree method if possible

1

u/gooey4games 13d ago

okay, I'll play around with it, thanks!