Question by
major.quin_n · Mar 08, 2016 at 08:35 AM ·
animation.play
Help With Playing an Animation With Play();
I am having trouble using the Play(); for type animation, it does not recognize it for some reason.
using UnityEngine;
using System.Collections;
public class GunAnimate : MonoBehaviour {
private int count = 0;
[SerializeField]
//private Animation gunShoot;
private GameObject weapon;
private Animation gunShoot;
// Use this for initialization
void Start ()
{
weapon = GameObject.Find("M4A1");
gunShoot = GetComponent<Animation>();
}
void Update ()
{
//Test if run key is down
if (Input.GetKeyDown(KeyCode.LeftShift))
{
transform.localRotation = Quaternion.Euler(0, 120, 0);
}
else if (Input.GetKeyUp(KeyCode.LeftShift))
{
transform.localRotation = Quaternion.Euler(0, 180, 0);
}
}
public void Shoot()
{
gunShoot.Play();
}
}
screenshot-4.png
(9.0 kB)
Comment