MissingComponentException: There is no 'Animator' attached to the "Gun" game object.

MissingComponentException: There is no ‘Animator’ attached to the “Gun” game object, but a script is trying to access it.
You probably need to add a Animator to the game object “Gun”. Or your script needs to check if the component is attached before using it.
UnityEngine.Animator.SetBool (System.String name, Boolean value) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/Animation/AnimatorBindings.gen.cs:277)
Gun.Update () (at Assets/gun/Gun.cs:25)

I am making a first person shooter game and i don’t need a Animator. Why is this error coming, all i wanted was to add animation to my gun. The sound is working but animation is not why. The script i am using is java script,

function Update () {
if(Input.GetButtonDown(“Fire1”)) {
var gunsound : AudioSource = GetComponent.();
gunsound.Play();
GetComponent.().Play(“GunShot”);
}
}

look like one of your script Assets/gun/Gun.cs is calling Animator.SetBool at line 25 which need an animator component
Can you show us the script?

i did

its java script
function Update () {
if(Input.GetButtonDown(“Fire1”)) {
var gunsound : AudioSource = GetComponent.();
gunsound.Play();
GetComponent.().Play(“GunShot”);
}
}

really strange because the error is referencing a c# script
Assets/gun/Gun.cs

i also have a C# script too
using UnityEngine;

publicclassGun:MonoBehaviour{
publicRigidbodybullet;
publicintbulletSpeed;
publicTransformbarrel;

//Usethisfor initialization
voidStart(){
}

voidSpawnBullet(){
Rigidbodyb;
b=Instantiate(bullet,newVector3(barrel.position.x,barrel.position.y,barrel.position.z),barrel.rotation)asRigidbody;
b.AddForce(b.transform.forward*bulletSpeed);
}

//Updateiscalledonceper frame
voidUpdate(){
//TODO:movemakethismore generic
if(Input.GetButtonDown(“Fire1”)){
SpawnBullet();

if(Input.GetButtonDown(“Fire1”))
GetComponent().SetBool(“shooting”,true);
}
}
}

here you go, you are refering to a Animator Component in this script that why you get this error

as a side note when you paste code please use the Insert… button, then choose code, this way the formating will be kept as is

like this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Director;

public class PhysicBlender : MonoBehaviour
{
    public float m_Weight;

    public AnimationClip m_Clip;

    private Animator m_Animator;

    private PlayableGraph m_Graph;
    private PlayableHandle m_ClipPlayableHandle;
    private PlayableHandle m_MixerPlayableHandle;

    private AnimationPhysicPlayable m_PhysicPlayable;

    private Rigidbody[] m_RigidBody;

    public bool m_Simulate;
    private bool m_OldSimulate;

    // Use this for initialization
    void Start()
    {
        m_Simulate = false;
        m_OldSimulate = false;
        m_Weight = 0.0f;
        m_Animator = GetComponent<Animator>();
        m_RigidBody = GetComponentsInChildren<Rigidbody>();
        for (int i = 0; i < m_RigidBody.Length; i++)
        {
            m_RigidBody[i].isKinematic = true;
        }

        m_Graph = PlayableGraph.CreateGraph();
        AnimationPlayableOutput playableOutput = m_Graph.CreateAnimationOutput("Mixer", m_Animator);
        m_MixerPlayableHandle = m_Graph.CreateAnimationLayerMixerPlayable(2);
        playableOutput.sourcePlayable = m_MixerPlayableHandle;
        m_Graph.SyncUpdateAndTimeMode(m_Animator);
        m_Graph.Play();

        m_PhysicPlayable = m_Graph.CreateAnimationPhysicPlayable().GetObject<AnimationPhysicPlayable>();

        m_ClipPlayableHandle = m_Graph.CreateAnimationClipPlayable(m_Clip);

        m_Graph.Connect(m_ClipPlayableHandle, 0, m_MixerPlayableHandle, 0);
        m_Graph.Connect(m_PhysicPlayable.handle, 0, m_MixerPlayableHandle, 1);
        m_MixerPlayableHandle.SetInputWeight(0, 1.0f);
        m_MixerPlayableHandle.SetInputWeight(1, 0.0f);
    }
}

I am new too unity. Now it giing me this error code
Assets/gun/gun fir.cs(18,10): error CS0246: The type or namespace name `AnimationPhysicPlayable’ could not be found. Are you missing an assembly reference?

Have you copy pasted my code to your script?

It was only to show you how to show code in the forum,
This code snippet won’t work in you’re unity version, it’s new Physic & animation blending stuff that i’m working on for the next version of unity