using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy1Animation : MonoBehaviour
{
Animator anim;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Player")
{
collided = true;
}
else
{
collided = false;
}
// Use this for initialization
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (collided = true)
{
anim.SetInteger("State", 1);
}
}
}
}
So this is the code I have- In my animator controller I have an Int Parameter called “State” and conditions on the transitions between walking and attacking in which State must = 0 for walk animation and 1 for attack animation. The image included shows the errors I got after attaching the script to an enemy prefab which also has an Animator Component with the correct Animator Controller. I’m very new to Unity and was relying on a tutorial for Animating my enemies but I can’t figure out what I’ve done to cause these errors- any help would be really appreciated, sorry if this is a really simple thing that I should already know. Like I said, I’m very new to Unity.