So, let’s get into this one and talk about Control Types (and secretly, blend trees).
As you learned about in our documentation and the previous walkthrough step, there’s a bunch of control types available to you in the Expression menu. There’s stuff as simple as Buttons or Toggles, essential like the Two and Four-axis controls, a little more esoteric like the Radial menu, and a little crazy like the Submenu. Let’s go over each one again.
First off, we’ve got Button. Button is very straight-forward! You define a Parameter to set, and then a value to set it to. When you select that button, the parameter is set to that value. When you un-select the button, the parameter is set to zero. That’s important! It does not reset to the previous value.
Toggle works very much like button in terms of the control setup-- however, when you move your cursor off the control, it doesn’t immediately turn to zero. Instead, it won’t reset until you unset the toggle.
Submenu is pretty crazy. You get to set a parameter to a value if you’d like, but you can also open another custom Expressions menu. Of course, that custom Expressions menu can also have a Sub Menu. And so on. And so on, and so on, and so on… its turtles all the way down, baby!
When you go into a submenu, the parameter is set to the value you specify. When you exit out of that particular submenu, the parameter is set to zero.
In the Two-Axis Puppet control, you get to choose three parameters:
- Main parameter (at the top)
- Parameter Horizontal
- Parameter Vertical
When you pull up this control, you get a representation of your joystick’s position. Of course, entering the menu also sets the main parameter to the value you’ve set, just like other controls. When you move that joystick around, you affect the Horizontal and Vertical parameters in a range of
Move the joystick up? Vertical goes to
1.0. Down? It goes to
How about left and right? You guessed it,
-1.0 for left,
1.0 for right. This is a X/Y coordinate system on a square piece of paper. You can now map out things to each of these directions!
Wait a sec this is a blendtree
You’re correct! Using this control to drive a Blend tree (OR setting the animations to Normalized Time) means that you can now blend between a ton of different face shapes, colors on a cube, dance types, etc. This is how the Nikei example does his crazy dance and face emotion blends.
This is super powerful and blendtrees are a vital part of Unity animations. There’s a bunch of them. Read about them in the Unity docs-- its super important to get an understanding of them if you want to get some serious power. It’s also how we drive locomotion! Here, just take a look:
This entire blend tree is driven off the values for velocity in the X (left/right) and Z (forward/back) direction.
@missstabby also has a great example of how you can build a 2D blend tree for non-locomotion stuff:
As you can see, she uses the X and Y values to drive what expression she’s selecting!
An important note– with the joysticks, you can’t really push to any variant of (1.0,1.0)-- as in, the corners of the “map”. The farthest you can go is about (0.7, 0.7), but this also depends on the controller you’re using and if your thumbsticks are working properly (pls gaben)
Keep in mind you also need a “neutral” motion-- you can just use a blank one at the center, and that should work fine. In addition, if you’re using this for face shapes, remember that you might want to disable eye automation while you’re doing face shapes, so you don’t blink over them. You can assign a state behavior to a blendtree, so that makes things easy.
Noooo blend trees are too complex aaaaaaaa
You don’t have to use a blend tree with 2D Axis, though. I don’t care about blending my face shapes on my model in a particular expression menu, so I use two-axis to simply detect if I go over 0.5 (well,
param > abs(0.5) but you get the point) and change my face. No blending, just basically a four-way Button control.
If you want to use blending, you can select “Normalized Time” in the motion state, set the parameter appropriately, and you’ll get cheap four-way blending.
Four-axis puppet is a little different-- you can set four variables instead of two! The values range from
1.0 instead. There’s a few cases in which this type of control will be more useful, but two-axis and four-axis control is pretty similar.
You can use the four-axis puppet with a direct blend tree to do some pretty cool stuff. Direct blendtrees are very straightforward-- you assign N parameters to it, and then drive N motions using those parameters. Of course, with 4-axis, you’re limited to 4.
Finally, we’ve got Radial Puppet. The “Parameter Rotation” describes how far you have “turned up” the outside bar. It’s kinda like a progress bar that you fill up!
Radial controls work especially well with a simple NormalizedTime motion, or with a 1D blendtree. That way, you can do something like adjust the length of your skirt or hair with a simple “progress bar” kind of control.
There’s a ton of cool things you could do with this alongside (for example) Normalize Time. You could change the speed that a light blinks on your avatar, morph your hair between short and long (or anywhere in between), all that kind of stuff.
As a tip (and this works with all controls), if you exit the control, then you keep the values you were adjusting within the control. Of course, if you end up exiting the state in which you’re animating, you don’t keep that animation playing. You’ll have to be a bit clever in detecting that you still want to keep that animation on. You can also attempt to unravel the mystery of Unity’s “Write Defaults” option, but uh… well, if you figure out exactly how that works, let me know.
This step is pretty straightforward-- try all the controls! Make something with each control type. It’s up to you to figure out what you want to do, but we want you to try out each one and let us know any difficulties you’ve had with any of the controls.
To be clear, try out each of these controls:
- Two-Axis Puppet
- Four-Axis Puppet
Again, it is up to you what you do with it! If you want to keep it simple and concentrate on figuring out the various controls, go for it. If you want to go a bit deeper and try blend trees, categorized submenus, custom graphics, all that jazz-- go for it! Good luck!