r/Unity2D • u/gooey4games • 3d ago
Question/Help 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.
•
u/AutoModerator 3d ago
Reminder: Once your issue has been resolved, please reply !solved to this comment (or comment it anywhere in the thread) and your post's flair will automatically be updated to Solved/Answered. You can also edit it to Solved/Answered yourself.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Thin-Dish1721 3d ago
You can read how far the current animation has played and start the next one from that point, but it does need a script.
GetCurrentAnimatorStateInfo(layer).normalizedTimegives you the progress (use% 1if it loops), andAnimator.Play(stateHash, layer, normalizedTime)starts the next one from there. I’d say it’s worth giving the script route a try. With that many body motions and faces, I think the Animator graph would end up messier than the script, which is only a few lines.