I am trying to make a fps game with custom animations but when i play the animation using a key the animation does not play but it dose not even show a error or something .I have even marked the animation as legacy. This is my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fire_Pistol : MonoBehaviour
{
public GameObject Pistol;
public GameObject GameManager;
public bool Firing = false;
public Animation Anim;
public GameObject MuzzleFlash;
void Start()
{
Anim = GameManager.GetComponent<Animation>();
}
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
if (Firing == false)
{
StartCoroutine(FireThePistol());
}
}
}
IEnumerator FireThePistol()
{
Firing = true;
Anim.Play("Fire_Pistol");
MuzzleFlash.SetActive(true);
yield return new WaitForSeconds(0.05f);
MuzzleFlash.SetActive(false);
Firing = false;
}
}