Quantcast
Channel: Questions in topic: "state machine"
Viewing all articles
Browse latest Browse all 42

Animation Event in state machine state

$
0
0
I have a simple Finite State Machine which i use, along with states, to control my enemy characters who currently have working states for Idle, Hunting and Attack (based on this tutorial: https://learn.unity.com/tutorial/finite-state-machines) This works great so far. I have now added an AnimationEvent in the Attack animation, however as its only StateMachine itself which is attached to the enemy GameObject, not the individual states (as this are instantiated by the StateMachine) I cannot attach this Event to the Attack state. Only functions within the StateMachine. I currently work around this by implementing the attack within the StateMachine, to prove it works. But I would like to keep my code clean and modular, so any suggestions how I can get my attack implementation into the attack state class and still be accessible from the AnimationEvent? Could this be done with a Delegate maybe?

Viewing all articles
Browse latest Browse all 42

Trending Articles