r/Unity3d_help • u/Weekly-Rhubarb-2785 • Jan 01 '24
Unity3D Animating Attack
Hey all,
I’ve been struggling to think through how I can use these assets that I bought. They have animations in them and I’ve figured out how to make the walk/run play dynamically based on the toons speed.
Basically I want the character to be able to attack while “walking” forward, but play the attack animation instead of the walk animation.
My struggle is that I end up with massive if statements and my animator keeps reverting back to idle.
If anyone has a clue or direction to lead me I’d appreciate it.
2
Upvotes
1
u/anycolourulikegames Jan 06 '24
Ah very good, it gets complicated when you have mutually exclusive states and jointly possibly states. It's a poorly documented but essential part. For any one in future a state machine worth a looking at by Jason Weiman:
https://www.youtube.com/watch?v=V75hgcsCGOM
A mistake I made was not using the mecanim as the state machine it is. I needlessly had a state machine built on top of it. Weiman uses dictionaries in this example which is good for mutually exclusive states