Mecanim Tips: 1D Blend Trees

Sharing is caring:

Learn to Blend Animations Using 1D Blend Trees

In this Unity tutorial we’ll go over the basics of using a 1D Blend tree using Mecanim. This video will be somewhat fast paced and will focus on the blend tree aspects to blend in 3 different animations; walk forward, turn left, turn right. This will be an update to an older tutorial regarding scripting in Mecanim but this will cover using it in Unity 5 and C#. You’ll need the Raw Mocap Data package from the Unity Asset store to follow along with this tutorial.

Below is the script used to control the movement in C#:

blending.cs (applied to character)

using UnityEngine;
using System.Collections;

public class blending : MonoBehaviour {

	private Animator anim;
	private float h;
	private float v;

	// Use this for initialization
	void Start () {
		anim = GetComponent<Animator> ();

	// Update is called once per frame
	void Update () {

		h = Input.GetAxis ("Horizontal");
		v = Input.GetAxis ("Vertical");

		anim.SetFloat ("Walk", v);
		anim.SetFloat ("Turn", h);


Jonathan Gonzalez

I love all things in game development and want to contribute by teaching others how to create games. I'm always looking to help others create awesome digital worlds. I've been a hardcore gamer since I was a kid and now it's my turn to create awesome digital experiences.

More Posts - Website

Follow Me:


  1. my character are walking in place animation. when I use them in your tutorial, character walks in place, how can I get them to move? Thanks in advance

  2. Thanks so much. He is now walking, but only vertical (W,S) and not Horizontal (A,D). How would I fix? Thanks in advance

    • That can be a bit more complicated. It can either be an issue with your script, make sure the parameter is written exactly as in your Blend tree. It can also be an issue with the transitions into the blend trees. So make sure you see the transition happening in the Animator controller.

  3. quick question…I downloaded my character & animations from mixamo, they come in as FBX Generic. When I convert them to humanoid or legacy they lose their animation pose. Is there a way to animate FBX Generic with your script? Thanks again!

    • Converting to Legacy is the old system and not really supported (won’t work with Mecanim). Generic just means it’s a basic animation usually used for non-humanoid objects. I’ve used Mixamo animations and usually just either convert them to humanoid or leave them as generic, but generic won’t support IK features which will create a more realistic “feel” to the animations. The rig and the animations should match for the rig type. I’ve used this same script with Mixamo animations and didn’t have issue. I’m not sure what you mean by “lose their animation pose”.

  4. what I meant when I convert to humanoid the aim idle pose the weapon closer to the body then normal. the generic pose work fine but the character wont move. can you show me how to strafe right and left. with the Script? Appreciate all Your help!
    Thanks In Advance

    • With a 1D Blend tree you could replace the current turning animations with strafing animations and the rest would be the same. If you wanted full motion in every direction you’d have to use a 2D Blend tree which is a bit more complicated to go over. I did create a full course on using rigged animations in Unity here: It includes using different types of blend trees and even includes a section on using Mixamo animations as well.

  5. Thanks You Very Very much!!

  6. good day
    hi I started the blend tutorial fresh. iam using mixamo generic character and generic aniamtion and did everything according to the video. the character will idle but wont move I check the parameters in the animator and everything is work. but the character is idling but still not moving. I have root motion check, I change the turn in the script to Strafe and also in the parameter window . all the spelling is correct. what can I do next? please help.
    Thank You

    • Did you disable “use exit time”? That’ll prevent the character from transitioning to the next animation until the current one is completed. If everything else is correct that would be the only thing I’d check.

  7. disreguard the previous comment. the only problem is the character not moving from Left,Right, although the animations are in the blend tree I press A or D the parameter numbers change but the character don’t Strafe.

    • Also note that in the video I used “mirror” to mirror the same animation over. Make sure that is not used if you have two separate animation clips for each movement. If all else fails you can create a new animator controller and just test out the animations separately. You can achieve the same effect without a blend tree as well. Just place each animation into it’s own state. Idle to each of the animations and back.

  8. good day

    the character is still Run forward in place only, and the Strafe Left and Right is do nothing.
    I check the script and its ok, and parameters and they all seem to be working fine, but the character.
    thank you for

    • Not sure what your issue is, but if the script is working properly then it’s an issue with the animator or animator controller transitions. I’d recommend recreating it to see if there’s something you overlooked.

  9. UPDATE: I fix the Parameter and condition now the character is running forward and strafing left and right but only in place.
    How to fix. thank A lot.

  10. I fix the parameter and conditions now the character is doing everything, but still walking, strafe Left and Right in place.
    its like there’s no translation to move the character around. please how to fix?
    thanks in advance.

  11. thank I got the character to move.

Speak Your Mind