How do you add strafe animations to a character?

I know this sounds dumb but i have made all the animations for my character. The last things are the strafe animations (side to side animations when they are only pressing “A” or “D” on the keypad)

The problem is, I don’t know where i would add these animations in the character motor. I have a different character motor than originally because i found one that offers more options.

Because im not sure on how to do this exactly in mechanim, i was just going to call the animations using JS when the player pushes one of those buttons. I just dont know when in the script it is called and what to put when it is called.

Help much appreciated here is my function fixedupdate and some of my function start
I tried to include as little as possible

function Start () {
	controller = GetComponent(CharacterController);
	myTransform = transform;
	speed = walkSpeed;
	rayDistance = controller.height * .5 + controller.radius;
	slideLimit = controller.slopeLimit - .1;
	jumpTimer = antiBunnyHopFactor;
	oldPos = transform.position;
}
 
function FixedUpdate() {
	var inputX = Input.GetAxis("Horizontal");
	var inputY = Input.GetAxis("Vertical");
	// If both horizontal and vertical are used simultaneously, limit speed (if allowed), so the total doesn't exceed normal move speed
	var inputModifyFactor = (inputX != 0.0 && inputY != 0.0 && limitDiagonalSpeed)? .7071 : 1.0;
 
	if (grounded) {
		var sliding = false;
		// See if surface immediately below should be slid down. We use this normally rather than a ControllerColliderHit point,
		// because that interferes with step climbing amongst other annoyances
		if (Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) {
			if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit)
				sliding = true;
		}
		// However, just raycasting straight down from the center can fail when on steep slopes
		// So if the above raycast didn't catch anything, raycast down from the stored ControllerColliderHit point instead
		else {
			Physics.Raycast(contactPoint + Vector3.up, -Vector3.up, hit);
			if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit)
				sliding = true;
		}
 
		// If we were falling, and we fell a vertical distance greater than the threshold, run a falling damage routine
		if (falling) {
			falling = false;
			if (myTransform.position.y < fallStartLevel - fallingDamageThreshold && enableFallingDamage == true)
				ApplyFallingDamage (fallStartLevel - myTransform.position.y);
		}
 
		// If running is enabled, change to run speed when left shift is pressed:
		if (Input.GetKey(KeyCode.LeftShift) && enableRun == true)
		{
			speed = runSpeed;
		}
		// If crouching is enabled, change to crouch speed when "c" is pressed:
		else if (Input.GetKey("c") && enableCrouch == true)
		{
			speed = crouchSpeed;
		}
		// If nothing is pressed, use walkSpeed:
		else
		{
			speed = walkSpeed;
		}
  1. Open up the animator (Window → Animator).

  2. Click on your character in the hierarchy you wish to add animations to.

  3. Now drag your animations into the animator (if they’re not already there).

  4. Add transitions between the animations you want to be able to switch from and to (you do this by right clicking on an animation in the animator and you’ll see an option to make a transition).

  5. Add a float parameter (bottom left corner of animator window). Call it speed or whatever you want.

  6. Click on the transition arrows you made in step 4 and set the condition to be based on the speed speed parameter you just made. For example, if the speed is greater than some number, you’ll want to strafe to the right.

  7. Create an instance variable ( aka field ) of type Animator. In your Start function add:

    animator = GetComponent();

  8. Finally, at the bottom of FixedUpdate, add:

    animator.SetFloat( “speed”, speed );
    //replace the string with whatever you named the parameter in the animator