Search Unity

my animation script returns errors help

Discussion in 'Animation' started by unity_M7CebJaEsAbc8g, Jan 23, 2020.

  1. unity_M7CebJaEsAbc8g

    unity_M7CebJaEsAbc8g

    Joined:
    Jan 23, 2020
    Posts:
    2
    errors saying
    The name "anim" does'nt exist in current context

    heres my code:

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

    public class animpizdiec : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    anim = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
    if (anim.GetCurrentAnimatorStateInfo(0).IsName("IDLE"))
    {
    if(Input.GetButtonDown("Fire 1"))
    {
    anim.SetTrigger("shoot trigger");
    }
    }
    }
    }

    looked on youtube and everybody seem to be using the same script
    help please
     
    Last edited: Jan 23, 2020