I have a collider attached to my weapon, (In a child gameobject) and would only like it activated during the attack animation and not when the player is just idling, however I don’t know how I would phrase the scripting to achieve such an effect.
public class Hand : MonoBehaviour {
private Animator anim;
public CapsuleCollider cc;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
cc.enabled = false;
}
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1"))
{
anim.SetBool("IsNoInput", false);
anim.SetBool("IsAttacking", true);
}
else
{
anim.SetBool("IsNoInput", true);
anim.SetBool("IsAttacking", false);
}
if (anim.SetBool("IsAttacking", true));
{
cc.enabled = true;
}
}
public void ActiveCollider(int active)
{
if (active == 0)
cc.enabled = false;
else
cc.enabled = true;
}
}
This current script leads to an “cannot implicitly convert type ‘void’ to ‘bool’” error.