I have a shotgun shooting animation, but i can’t get it to play. Here is my Animator component:
Now here is my script:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class AimSys : MonoBehaviour
{
bool Click = false;
bool target = false;
public float fireRate = 0.5F;
private float nextFire = 0.0F;
public GameObject Flash;
public Animator anim;
void Update()
{
nextFire -= Time.deltaTime;
if (Input.GetButton("Fire1") && target && nextFire <= 0)
{
anim.SetTrigger("Shoot");
AudioSource audio = GetComponent<AudioSource>();
audio.Play();
Flash.SetActive(true);
Debug.Log("Target Hit!");
nextFire = fireRate;
}
}
void OnCollisionEnter(Collision collision)
{
{
if (collision.gameObject.tag == "Enemy")
target = true;
}
}
void OnCollisionExit(Collision collision)
{
{
if (collision.gameObject.tag == "Enemy")
target = false;
Flash.SetActive(false);
}
}
}
What i want to do, is when the player click with the left mouse button (fire1), some effects are displayed such as sound effect and image effect, BUT ALSO i want my shooting animation to be played. The problem is that nothing happens! I didn’t get any error, but still my animation just doesn’t play. Could someone help me here?