I can't assign animator controller into the script.

Hi! I’m trying to make animation but i cant assign animator controller into script. I’ve already declared public Animator and it gives me this error:
UnassignedReferenceException: The variable arms of GunSystem has not been assigned.
You probably need to assign the arms variable of the GunsSystem script in the inspector. (Script’s name is GunSystem)

Whats going on? Here’s my script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SystemBroni : MonoBehaviour
{
public BronEnum ChoisenWeapon;
public Animator arms;
void Start()
{

}

void Update()
{
if(ChoisenWeapon == WeaponEnum.Pistol)
{
arms.SetBool(“Pistol”, true);
}
}
}

It means, player is taking pistol to his arm and the “TakePistol” animation should by turned on.

Did you drag an Animator object into the slot in the inspector? If you dropped the script on the same object that has the Animator component, you can also add this to the Start() method:

private void Start() {
    arms = GetComponent<Animator>();
}
2 Likes