- Home /
mecanim blend tree attack combo
So im trying to make attack combos, i think using a blend tree would be the solution but i dont know how to do it, i can set up a blend tree, but im lost on the scripting of the combos. Its gonna be like a hack'n slash, the user can spam the attack button to do consecutive attacks, and after the third a pause. If the user does not push the attack button withing a certain amount of time after the previous attack it resets.
I dont think it's exactly mechanim related, you would still just transition between regular animation states. $$anonymous$$ore important would be how you handle the combos in your controller/Input scripts. I would suggest having classes with arrays of actionTypes (and finisher) as combo-templates And an ExecuteAction(Actiontype) method on your character. Then your character keeps a list of the last executed actions (with a certain timeframe before clearing it) and if these actions match to some combo templates, collect the templates that also match and do that after each player action until there's one left and execute its finisher action.
Answer by Positive7 · Jul 29, 2015 at 10:06 AM
Something like this?
using UnityEngine;
using System.Collections;
public class test3 : MonoBehaviour {
public float time = 3.0f;
public Animator anim;
public float Attack;
public bool startTimer;
void Start () {
anim = GetComponent<Animator> ();
}
void Update () {
if (Input.GetButton ("Fire1") && time > 0) {
Attack++;
startTimer = true;
} else if (time <= 0.0f) {
Attack = 0.0f;
}
anim.SetFloat ("FloatName", Attack);
if (startTimer) {
if(time >= 0){
time -= Time.deltaTime;
}else if (time <= 0){
time = 3.0f;
startTimer = false;
}
}
}
}
I must admit that you algorithm is the best I've seen so far from looking at other "combo attack script". Simple, but efficient.
Gratz m8.
Answer by MrTindervox · Jul 11, 2018 at 01:05 PM
if (Input.GetButton ("Fire1") && time > 0)
{
Attack++;
startTimer = true;
} else if (time <= 0.0f) {
Attack = 0.0f;
time = 3.0f;
startTimer = false;
}
anim.SetFloat ("FloatName", Attack);
if (startTimer) {
timer -= Time.deltaTime;
}
Pretty sure this would yield the same. Plus <= in else if would never trigger cause >= is in if statement.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Mecanim Making an NPC walk 1 Answer
How to control damage output. 0 Answers
How to get default animation for layer 0 Answers