I’ve created a bow with full animations and I’d like to assign them using mechanim. My code has been having alot of issues and I don’t know that I’m on the right track. Any clues? Thanks.
using UnityEngine;
using System.Collections;
public class mechanim : MonoBehaviour {
Animator anim;
static bool idleState = Animator.StringToHash("Base Layer.Idle");
static bool reloadState = Animator.StringToHash("Base Layer.reload");
static bool pullHoldState = Animator.StringToHash("Base Layer.pullHold");
static bool waitFireState = Animator.StringToHash("Base Layer.waitFire");
static bool fireState = Animator.StringToHash("Base Layer.fire");
static bool failAttemptState = Animator.StringToHash("Base Layer.failAttempt");
void Start ()
{
anim = GetComponent<Animator>();
}
void Update ()
{
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
/*float move = Input.GetAxis ("Vertical");
anim.SetFloat("Speed", move);
if(Input.GetKeyDown(KeyCode.Space) && stateInfo.nameHash == runStateHash)
{
anim.SetTrigger (jumpHash);*/
}
void FixedUpdate ()
{
if(Input.GetButtonDown("Fire1"))
{
anim.SetBool(reloadState, true);
//then pullHold
//then waitFire
}
if (Input.GetButtonUp ("Fire1") && (waitFireState == true))
{
anim.SetBool (fireState, true);
}
else if (Input.GetButtonUp ("Fire1") && (waitFireState == false))
{
anim.SetBool (failAttemptState, true);
}
}