Thanks for checking my question out, I am having so much trouble trying to get my player to play an animation. I have an animation controller on my gameobject, a transition named Shoot in my animator and a button that runs ShootBullet(). I get the error that says “Animator is not playing a Playable”. I am not sure what to do, I have looked at dozens of websites for help with no luck. I am not sure if it has something to do with my player being a prefab and getting instantiated into the game, but either way I would have no idea how to fix that. I will include my script and a screen shot of my Animator. I would love to get some feedback because I have been stuck on this for quite some time now. Thanks for the help!
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
public class RaycastGun : MonoBehaviour {
public Rigidbody Bullet;
public float speed = 20;
public Animator anim;
int shoot = Animator.StringToHash("Shoot");
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
anim.enabled = true;
}
// Update is called once per frame
void Update () {
}
public void ShootBullet()
{
anim.SetBool (shoot, true);
Rigidbody instantiatedProjectile = Instantiate (Bullet, transform.position, transform.rotation) as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection (new Vector3 (0, 0, speed));
}
}