Fungus animation in Unity

Okay, so the basic Animator in Unity can be intimidating to someone just learning.

A lot of the tutorials for animation in Unity start right into creating transitions between states and using variables to trigger transitions, and sometimes that’s overkill for what you want to do.

There is a function for the Animator class, it’s called Animator.Play. It’s often overlooked, (even that script reference I just linked doesn’t describe it) but it’s pretty nice if you want to cut to the chase and don’t want to use anything fancy.

I’ve been playing a little with the Fungus engine, which is designed for making visual novels, and have node-based flow control.

For the built-in animation commands in Fungus, there are Set Anim Trigger, Set Anim Float, etc. These are all ways to set variables on the animator, and then if you’ve got transitions that activate based on those variables, then the transitions change the state of the animator. So using them requires you set up variables and transitions for whatever you’re doing.

So I figure, sometimes you want to cut out the middleman, and just change states directly. So I made my own Fungus command that lets you directly change state.

Here’s what it looks like in action:
Display of Unity Animator and Fungus command

In the Animator, you can just add states by dragging in animations. You don’t need to make any transitions between states. In the Fungus command, the State Name parameter should be the name of the state that appears in that Animator flowchart. I’ve included Layer parameter in the command, though if you do want to keep it simple, just leave it with the default -1 and leave your animator with the default base layer. The time parameter lets you start the animation part-way through the clip, so 0 will play from the beginning, 0.5 will start half-way through, etc.

You can download the script for this command here.

This entry was posted in uncategorized and tagged , . Bookmark the permalink.

Comments are closed.