Author Topic: Playmaker Animation Without Using Mecanim  (Read 1130 times)


  • Playmaker Newbie
  • *
  • Posts: 16
Playmaker Animation Without Using Mecanim
« on: July 21, 2023, 02:37:36 PM »
Hey everyone,

Background here, skip to later for TLDR:
I've been recently trying to learn Unity's mecanim system, with its quirks, oddities, and limitations. I've tried my best to use mecanim, but every time I did, I wound up with a spaghetti monster of lines and substates all tangled together.

I tried having every state be called from a common any state, but it was way too difficult without playmakers powerful ability to call states with complex logic. All you get in macanim is bools floats triggers and ints. You could design that logic in playmaker, then flip a boolean/trigger per blend tree/animation, but then you still need to create every transition manually in mecanim, not to mention now tracking potentially hundreds of animator specific variables in playmaker. This felt like so much wasted work, like I was being forced to design the same FSM twice in an inferior system.

I saw a couple videos on youtube about controlling mecanim from code, and just have the blend trees and animations merely live in the animator. But that lacks mecanims ever so smooth animation transitions which are super important to a convincing 3d character. Most of these videos were aimed at 2D sprite animation.

Enter cross fade!!

Calling the cross fade function allows you to call an animation or blend tree directly from playmaker and have it blend from the current animation just like a mecanim transition would. However there's one huge problem. It uses normalized transition duration. So let's say you have a 10 second idle animation, and a 0.5 second attack animation using a transition duration of 0.25.

Transitioning from the idle to the attack would blend for 2.5 seconds, longer than the attack animation itself! Transitioning from the attack animation to the idle would blend for 0.125 seconds, which would probably be too fast. You would have to set each one up manually by doing the math which sounds like way too much work to me.

Which is why we need CrossFadeInFixedTime! This function works exactly like CrossFade, only allowing the blend to occur in a fixed time in seconds which is super convenient. You can just leave it at a default of 0.25 seconds (which mecanim uses as a default transition time), and 99% of your transitions will look great, called directly from your playmaker FSM.

The only Slight problem is that playmakers animator package only has the CrossFade function, so I made a fixed time version for you, attached below.

TLDR: I recommend you try designing your characters animation logic in playmaker using CrossFadeInFixedTime. And playmaker devs, I strongly recommend you add the function to playmaker's animator package. Perhaps I am missing a good use case scenario for regular CrossFade, but it is significantly less useful than CrossFadeInFixedTime in the majority of situations IMO.