Help understand the connection between the speed of animations in the animator code

The title might be confusing a bit - I’ve been following along the stealth project tutorial - in the player movement part:

	void ManageMovement(float horizontal, float vertical, bool isSneaking)
	{
		anim.SetBool(hash.sneakingBool, isSneaking);

		if (horizontal != 0 || vertical != 0)	// if there's any movement
		{
			ManageRotation(horizontal, vertical);
			anim.SetFloat(hash.speedFloat, 5.5f, dampSpeed, Time.deltaTime);
		}
		else
		{
			anim.SetFloat(hash.speedFloat, 0f);
		}
	}

One more thing that is quite confusing me - it’s the speed of all what’s happening! - if we look at the animator, we’ll see that the speed of all the animations is set to ‘1’ (I don’t know what that means) - I know that if you lower the locomotion animation speed to 1.5 or something you’ll get the player to walk, and 5.5 to run - on line 23 we’re setting the “Speed” float variable to 5.5

    anim.SetFloat(hash.speedFloat, 5.5f, dampSpeed, Time.deltaTime);

But I just don’t see where in the animator did we bind between this ‘Speed’ variable and the locomotion animation speed! - and yet if we manipulate this variable’s value the animation speed changes, how?

One other thing, if we set the ‘Speed’ to 5.5, shouldn’t the stealth animation also be at 5.5? - I’m confused - how is the speed of the animations handled in the animator and in code? how is everything connected? ((

The speed variable is nothing more than a variable to define what animation to play, so if speed is greater than say 1 we are running forward, less than 1 but greater than 0, we are walking forward, the speed variable in that example does not change the animation speed, it simply is a way to play the correct animation based on speed. I think the idea is that mecanim should handle all locomotion and transitions so your walking, running, attacking etc should move the player forward or make them jump, without scripting. I found mecanim to be quite limiting atm, because there is no proper events system (apart from curves) and issues about adjusting individual clips to tidy stuff up in the editor, as i am no animator or modeler, something i can use to clean up animations would be great.

Thanks for your answer - kinda made it clearer :slight_smile:

Also, for people in the future stumbling across this thread, I found this very simple, detailed, 4-videos tutorial on mecanim, helped me a lot.

Also, officially from Unity: