Creating a fighting system with mecanim

So i have been working with Mecanim to create my own character controller, I have the basic movement down to a t, but im having trouble trying to create a simple fighting system with 4 main animations; kick 1/kick2/punch1/punch2.

I want to create a simple blend tree that will blend the animations if and when they are pressed within seconds of each other. But how should this be set up?

Should I add 4 Bool’s in the parameter box (each of the animation motions) and have this called upon similiar to the jump feature in the Mecanim Tute?
Or am i trying to make something more complicated than it needs to be?

I have this line of code to activate the move(s), I copied and pasted with minor changes for every other animation file. I tried this out with my 4 Bool parameters in place and gave it a transition too and from the locomotion blend tree and the idle state but it didnt play the animations I was trying to activate with the corresponding keys.

if(Input.GetButtonDown(“O”)){
animator.SetBool(“Punch1”, true );}

I have basically followed the steps of the main Mecanim Tute (the 40min video on youtube) so my characters animator is layed out exactly like that using the BotCntrl script which i have modified with 4 lines of code, like the example above.

any help/advice what so ever would be greatly appreciated

Hmm, I’ve never tried to do this before, but my thought would be to have an int, rather than a boolean. Then on button press, have a function that adds one to that int, yields for a second or two, then subtracts one. That way you can test for multiple presses of the same button, like ‘up up up.’

Actually, that might not be the best way, because that won’t let you order things. Maybe have an array of key presses as strings? Again you call a function, it adds the key to the end of the array, waits a set number of seconds, then removes it. You check the array on each key press, and if it matches any one of a number of preset combinations, you do your combo move.

Sounds like a fun thing to do.

Something that it came to me is: having an int represents each botton key. Then an int array which reads when keys are pressed and finally use cases on int combinations of the int array, to have the corresponding movement. (Also when it reads the array having a time delay between each stroke to read next or start from zero) so it doesn’t reads previous keystrokes if time passed.Needs a time offset. Since u r using mechanim it reads input data of axis or any input so this is great for continues movement to blend combos

you should look into mecanim trigger its like a bool but it auto resets when you use it so you could do on button down activate trigger and then keep taping to keep the trigger active and have the animation on a exit time so if you dont get a trigger it will go back to idle of wat u want

Unity - Scripting API: Animator.SetTrigger link to trigger doc

but my problem is timeing the animtatin for an even like i set waitForEndFrame so it has time to change the animation then yeild wait animation length or what u need the active event but timing it is hard lol i am goin to try a time.deltatime when i get home

I have it taken care of in my video

But if you prefer button mashing

if (Input.GetButtonUp("Punch"))
			{
				animator.SetBool("punch", true);                
			}