Animator Transitions Get Scary…FAST!

The image above says it all – what it DOESN’T say is that the image is the CLEANER version.  All of the transitions on the right side (which represent actions and reactions) were originally tied in and out of the 3 movement blend trees.

If you didn’t understand any of that, you will..

Blend Trees

these are nice, neat ways Unity blends a set of animations together based on input values.  The most common use is transitions from idle to walk.  If you have enough animations, you can even expand this to be idle, sneak, walk, jog, run, sprint, etc…  In my game, my character controller is set to output a speed value each of the 3 movement transition blend trees interpret to set the type of movement.  Think of it like interpreting an analog controller.  The farther I push the stick, the faster I want the character to move.  Blend Trees handle the transitions; my controller script handles the movement.

You can read more in Unity’s documentation.

 

What I worked on this week:

This little video says it all.  Animation transitions for most actions are in.  I can make Jenny do lots of mean stuff to Ol’ Prefab Pete here.  (I have WAY too much fun throwing stuff at this guy…he just spins and spins because I didn’t set friction on him!)

I still have a lot of work to do with the player controller to get things smooth and responsive.  The transitions between pickup and movement aren’t as smooth as I’d like them to be, and the delay after a throw slows the pace more than I’d like.

This little video says it all.  Animation transitions for most actions are in.  I can make Jenny do lots of mean stuff to Ol’ Prefab Pete here.  (I have WAY too much fun throwing stuff at this guy…he just spins and spins because I didn’t set friction on him!)

I still have a lot of work to do with the player controller to get things smooth and responsive.  The transitions between pickup and movement aren’t as smooth as I’d like them to be, and the delay after a throw slows the pace more than I’d like.

What did you do?

I attached a special script called an Animation Behavior on all of my action animations.  The script controls a bool that turns TRUE as it transitions in; then FALSE as it transitions out.  This value is polled by the player controller to keep the player from spamming multiple actions at one time – avoiding A LOT of animation “hiccups” due to bad / unrealistic transitions.

Here’s a video from BugZerg Arcade explaining the concept.  The video is old – and he’s doing something more advanced than I needed, but the core concept is the same.

It was that easy?  Just 2 lines of code?

Of course not.  The Animation Behavior solved the problem of overlapping transitions, but I still needed to time Jenny’s object pickup and throw animations with all of the other events that need to take place.

  • Attaching (parenting) the object to Jenny’s hands on pickup.
  • Disabling physics while the object is being carried.
  • Decoupling (un-parenting) the object on a throw.
  • Adding force on throw.

Each of these was a separate challenge, and one I’ll do a tutorial on sometime so the Internet can destroy my methods in the comment section.  🙂

What’s next?

With a lot of my basic transitions prototyped, I’m moving on to some of the other core mechanics in the game.  I need to be able to throw inventory objects next…most of that code is in place and waiting to be linked.  Tool usage, the shipping bin, and a shop will be next.

I’ve also got a bug where I can change inventory slots while carrying an object, which results in the game leaving the object permanently parented to Jenny’s hand.

Basically, I’m using a test scene that features each of the games interactions in a sort of lab test environment.  I build and test there, then create prefabs that can be used in the actual levels.