How do I call on Animations for idle, walk, and run

I have been loosing my mind for a while now trying to learn all this. I finally switched all of my Animation from Legacy to Humanoid so that I could use the Animator Controller and yet I still am running into the same problem (And then some) I originally was trying to run the Animations through the Legacy and could not get the speed of the animations right in the scripting, nor able to call on Run animation whil I was walking. and so switched everything to Humanoid. Now I can not get it to change the Int so that it calls up the different animations AND it wobbles my Camera left and right with the Idle process… PLEASE I am totally lost on what to do. I am running 5.4

public class UnitPlayer : Unit
{
    private Animator animator;

    // Use this for initialization
    public override void Start()
    {
        animator = GetComponent<Animator>();
        base.Start();
    }

    // Update is called once per frame
    public override void Update ()
    {
        // rotation

        transform.Rotate (0f, Input.GetAxis ("Mouse X") * turnSpeed * Time.deltaTime, 0f );

        // movement

        move = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));

        move.Normalize();

        move = transform.TransformDirection(move);
        animator.SetInteger("Speed", 1);

        if (Input.GetKey (KeyCode.Space) && control.isGrounded)
        {
            jump = true;
        }

        running = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
        animator.SetInteger("Speed", 2);
        // animation


        base.Update();
    }
}
using UnityEngine;
using System.Collections;

[RequireComponent (typeof (CharacterController))]

public class Unit : MonoBehaviour
{

    protected CharacterController control;

    protected Vector3 move = Vector3.zero;

    public float walkSpeed = 4f;
    public float runSpeed = 8f;
    public float turnSpeed = 15f;
    public float jumpSpeed = 5f;

    protected bool jump;
    protected bool running;

    protected Vector3 gravity = Vector3.zero;

    // Use this for initialization
    public virtual void Start()
    {

        control = GetComponent < CharacterController >();

        if (!control)
        {
            Debug.LogError("Unit.Start[) " + name + " has no CharacterController!");
            enabled = false;
        }
    }

    // Update is called once per frame
    public virtual void Update()
    {
        // control.SimpleMove(move * moveSpeed);

        if (running)
            move *= runSpeed;
        else
            move *= walkSpeed;

        if (!control.isGrounded)
        {
            gravity += Physics.gravity * Time.deltaTime;
        }
        else
        {
            gravity = Vector3.zero;

            if (jump)
            {
                gravity.y = jumpSpeed;
                jump = false;
            }
        }

        move += gravity;

        control.Move(move * Time.deltaTime);
    }
}

and this is my failed attempt at making the Animations work with Legacy and everything in Javascript

#pragma strict

function Start () {


}

function Update () {

    if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
    {
        //animator.SetInteger("Speed", 1);

    }
    else
        // (Mathf.Abs(Input.GetAxis("Vertical")) < 0.1)
    {
       // animator.SetInteger("Speed", 0);
    }

    if (Mathf.Abs(Input.GetAxis("Vertical")) > 8)
    {
       // animator.SetInteger("Speed", 2);
    }
}
   // if (Input.GetKey ("w") || Input.GetKey ("s"))
    //{
      //  GetComponent.<Animation>().Play("Walk");

    //}
    //{
      //  if (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))
        //{
          //  GetComponent.<Animation>()["Run"].speed = 10.0f;
           // GetComponent.<Animation>().CrossFade("Run");
       // }
       // else
        //{
         //   GetComponent.<Animation>().CrossFade("Idle");
        //}
  //  }

Someone PLEASE help!

Why not just set the speed as a Float in Mecanim? That way you could do all your transitioning based on the actual speed value instead of trying to partition it out into pieces.

Because from the tutorials I read about using a float, the animations would just quickly transition from Idle to run barely playing the Walk. I want the Player to be able to walk AND run by hitting the Shift key and only when the Shift key is pressed.

*** Walk by w and run by w and shift **** <— clarification

Ok, I started over on the Animation yet again… Here is the code I am using now…

using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour
{
    Animator anim;
    int jumpHash = Animator.StringToHash("Jump");
    int runStateHash = Animator.StringToHash("Base Layer.Run");


    void Start()
    {
        anim = GetComponent<Animator>();
    }


    void Update()
    {
        float move = Input.GetAxis("Vertical");
        anim.SetFloat("Speed", move);

        AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
        if (Input.GetKeyDown(KeyCode.Space) && stateInfo.nameHash == runStateHash)
        {
            anim.SetTrigger(jumpHash);
        }
    }
}

But as stated in previous Reply, It switches straight through the walk animation to Run animation without me pressing Shift key. How do I, (And do not mind watching or reading a tutorial on this) make it where my player only runs when I hit shift?

Also I am running into a problem where (even though I set the Speed Param to 0.1) it takes about a half second to a second for the animation to switch from Idle to anything else.

I am also still having the problem where the camera is swaying left and right with the Idle animation.

Take a look at your Transitions in the AnimatorController. There are a few options that change the behavior.
Check out what “Has exit time” does for example.
You should post a picture of your graph for better help :wink:

Why do you use the getaxis vertical? Thats the mouse input.
Try getkeydown w.
And then you just need two bools in your animator for walk and run and dependent translations.

I tried the getkeydown and it continuously played walk even when I have the shift key pressed with W for run using getkeydown as well. So I was told to switch to float. Please understand I am a noob when it comes to Unity and C# so please explain further.

Did you adjust your Transitions? Entry → Idle - (Walk = true) → Walk - (Run = true) → Run

yes. thats ok, I am starting over with a new style script. I will see if that works.