Question by
matthewcooper · May 10, 2020 at 08:09 AM ·
c#mobilebutton trigger eventscombat
Setting up a attack button
I'm trying to make it so when a button is pressed it will attack but I can't seem to get it right, I'll show the code that I've tried below. Can anyone help me with this?
public class PlayerCombat : MonoBehaviour {
// Animation Event
private Animator animator;
// Use this for initialization
void Start() {
animator = GetComponent<Animator>();
}
void Update() {
KnightHeroAttack();
}
public void KnightHeroAttack() {
animator.SetTrigger("KnightHeroAttack");
}
}
}
Comment