Anim nameHash help needed!

I cant get this to work.:

using UnityEngine;
using System.Collections;
// Getting components
[RequireComponent(typeof (Animator))]

public class CharacterMotor : MonoBehaviour
{
    public Animator anim;
    public int SpeedFloat;
    public int JumpBool;
    public int DirectionFloat;
    public int IdleState;
    public int LocoState;
    public int JumpState;
    public int BackState;
    private AnimatorStateInfo currentBaseState;   



    void Awake()
    {
        SpeedFloat = Animator.StringToHash("Speed");
        JumpBool = Animator.StringToHash("Jump");
        DirectionFloat = Animator.StringToHash("Jump");
        IdleState = Animator.StringToHash("first.Idle");
        LocoState = Animator.StringToHash("first.Locomotion");
        JumpState = Animator.StringToHash("first.Jump");
        BackState = Animator.StringToHash("first.Bacmotion");

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

   
    }
   
    void FixedUpdate ()
    {
        float h = Input.GetAxis("Horizontal");   
        float v = Input.GetAxis("Vertical");
        anim.SetFloat("Speed", v);           
        anim.SetFloat("Direction", h);
        if(currentBaseState.nameHash == IdleState)
        {
            print ("Should work?");
        }
    }
}

Any help apriciated, thanks.

Anyone?

Is the parent state named “first” (case-sensitive)? This would be the containing sub-state machine, or the layer name if “Idle” isn’t in a sub-state machine.

1837198--117799--xxx.PNG

Can you post the code where currentBaseState is assigned?

its assigned in this script.

  if(currentBaseState.nameHash == IdleState)
        {
            print ("Should work?");
        }

Line #1 above only checks the value. You need to assign it first. Try this:

void FixedUpdate ()
{
    float h = Input.GetAxis("Horizontal"); 
    float v = Input.GetAxis("Vertical");
    anim.SetFloat("Speed", v);         
    anim.SetFloat("Direction", h);
    currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // <-- add this line
    if(currentBaseState.nameHash == IdleState)
    {
        print ("Should work?");
    }
}

Thanks for the reply