Trouble changing my animation state

My script was working perfectly but my animation controller disappeared, I made a new one but for some reason the script is no longer changing my animation state. This is my script;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AnimScript : MonoBehaviour {

    private Animator anim;

    void Start () {

        anim = GetComponent <Animator> ();
       
    }
   

    void Update () {

        if (Input.GetKeyDown ("up")) {
            anim.SetInteger ("State", 1);
        }
        if (Input.GetKeyUp ("up")) {
            anim.SetInteger ("State", 0);
        }
    }
}

My animation controller is called Animations but I don’t think that should matter, what am I doing wrong??

Which component you are using?

Animation
3478691--276623--upload_2018-4-30_14-40-38.png

or Animator
3478691--276624--upload_2018-4-30_14-40-55.png

I’m using Animator

Does it need to have the Avatar assigned in the component? Looks like it’s not in that screenshot. Check that maybe?

That wasn’t my screenshot above, that was someone’s example this is what I’m working with:
3479549--276723--Screen Shot 2018-04-30 at 4.28.44 PM.png
I didn’t need an avatar before, this issue is that my script is not accessing my state variable inside the animator and I’m not sure why.

I’ve tried deleting the animation component and that didn’t help it, I have no idea why the variable is not being accessed

I GOT IT! The answer wasn’t in the question so you guys couldn’t have figured it out but I really appreciate the effort. My issue was that “State” in the animator was actually a float value, not an integer, and so it was not changing the value. I really appreciate the help though, you guys are awesome!

Hehe, glad you got there! That has got me before too :sweat_smile: