Hey guys im trying to make my animation work for my 3d game but for some reason it’s not working please help me:
This is my code and for some reason if i use: if (Input.GetMouseButtonDown(0)) then my animation doesn’t play at all but if i use: if (Input.GetKey(KeyCode.D)) then my animation works but for some reason it only works when i hold “D” please let me know what iam doing wrong and how i can make my animation work when i press my Right mouse button
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class chop : MonoBehaviour {
private Animator anim;
public bool Chopping;
// Use this for initialization
void Start () {
anim = gameObject.GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
anim.SetBool("Chopping", Chopping);
}
void FixedUpdate()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Pressed mouse button.");
Chopping = true;
anim.SetBool("Chopping", true);
anim.Play("Chop");
}
if (!Input.GetMouseButtonDown(0))
{
Chopping = false;
anim.SetBool("Chop", false);
}
}
}