LocomotionSystem not working in Unity 5

I’m fairly new to scripting and I’m trying to test the Locomotion System asset in Unity 5 so I can use procedural animations in my project, but when I hit play the legs don’t animate and I get these error messages:

The lines in the LegController script creating these errors are as follow (respectively):

(LegAnimator.cs line 254)

controlMotionState.enabled = true;

(LegAnimator.cs line 390)

MotionGroupState group = motionGroupStates[g];

(LegAnimator.cs line 1889)

switch (legState.phase) {

I couldn’t get the character to move using the NormalCharacterMotor script, so I wrote my own movement script which works fine:

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(CharacterController))]
public class movement : MonoBehaviour
{

Vector3 direction = Vector3.zero;

void Update () 
{
	CharacterController controller = GetComponent<CharacterController>();
direction = new Vector3(Input.GetAxis("hori_left_stick"),0,Input.GetAxis("vert_left_stick"));
controller.Move(direction);
}

}

Other than the movement script, everything is set up according to the documentation. The Animation component is attached and contains the all the animations including the ones I’m targeting (“idle1” and “walkForward”). I’ve searched and searched but haven’t found a relevant answer. Is this some sort of Unity 5 compatibility issue?

OK, as nobody else answered, I started to have a look myself :wink:

… and here are my first results.

The problem is the animation system.
Unity 5 REQUIRES to mark “LEGACY ANIMATION” as such.

So you need to change the two commands where the “DUMMY ANIMATION” is created and mark them explicitly as legacy like this:

Near Line 254:

			// Create dummy animation state with control motion name
			//GetComponent<Animation>().AddClip(new AnimationClip(), "LocomotionSystem");

			AnimationClip newAnim = new AnimationClip();
			newAnim.name = "LocomotionSystem";
			newAnim.legacy = true;
			GetComponent<Animation>().AddClip(newAnim, "LocomotionSystem");

Near Line 285:

				// Create dummy animation state with motion group name
				//GetComponent<Animation>().AddClip(new AnimationClip(), legC.motionGroups[g].name);

				AnimationClip newLegCAnim = new AnimationClip();
				newLegCAnim.name = legC.motionGroups[g].name;
				newLegCAnim.legacy = true;
				GetComponent<Animation>().AddClip(newLegCAnim, legC.motionGroups[g].name);

I’m working with Unity 5.2.2f1 and I had to do it this way:
Line 251:
// Create dummy animation state with control motion name
//GetComponent().AddClip(new AnimationClip(), “LocomotionSystem”);

			AnimationClip newAnim = new AnimationClip();
			newAnim.name = "LocomotionSystem";
			newAnim.legacy = true;
			GetComponent<Animation>().AddClip(newAnim, "LocomotionSystem");
			controlMotionState = GetComponent<Animation>()["LocomotionSystem"];

and then Line 287:
// Create dummy animation state with motion group name
//GetComponent().AddClip(new AnimationClip(), legC.motionGroups[g].name);

				AnimationClip newLegCAnim = new AnimationClip();
				newLegCAnim.name = legC.motionGroups[g].name;
				newLegCAnim.legacy = true;
				GetComponent<Animation>().AddClip(newLegCAnim, legC.motionGroups[g].name);
				controller = GetComponent<Animation>()[legC.motionGroups[g].name];

hope this helps :wink:

Thanks for the tips guy…
It also spat a few errors about Horizontal2, Vertical2 and Sneak not being set up in the Input Manager.
I just duplicated Horizontal and Vertical, and renamed them with the “2” on the end.
And I duplicated Fire and called it “Sneak”, and it all worked!