I did it by creating a data system that works like this
new Stance { Name = "Sword and Board Punch Attack 1", Animation = "Sword and Board Punch Attack", Looping = false, CanResume = false, Layer = 0, },
new Stance { Name = "Sword and Board Punch Attack 2", Animation = "Sword and Board Slash Attack 1", Looping = false, CanResume = false, Layer = 0, },
new Stance { Name = "Sword and Board Punch Attack 3", Animation = "Sword and Board Slash Attack 1-2", Looping = false, CanResume = false, Layer = 0, },
These are the different gameplay states the character can be in.
Next, I use a set of data to list the timing windows for when inputs can cause you to change from one attack to another:
{
"Sword and Board Punch Attack 1",
new List<Branch>()
{
new Branch { OnTime = 0.1f, PlaySound = SwordSwing1, },
new Branch
{
On = 0f,
MovementLock = true,
},
new Branch
{
Signal = Signal.StanceEnter,
Translation = Trans_Sword,
},
new Branch {
Signal = Signal.StanceEnter,
Action = context => {
SwordAndBoardHitbox.AttackName = "Sword";
SwordAndBoardHitbox.HitDirection = RelativeVector(1f, 0f).normalized;
AttackDatabase["Sword"].NextAttackID();
Stats.Properties["LastAttack"] = 1;
},
},
new Branch
{
IsAttack = true,
On = 0.0f,
Off = 0.25f,
Condition = ShouldKneelAttack,
NextStance = "Sword and Board Kneel Punch Attack",
KeepProgress = true,
},
new Branch
{
IsAttack = true,
On = 0.0f,
Off = 0.25f,
Condition = ShouldDiagonalUpwardAttack,
NextStance = "Sword and Board Punch Attack Diagonal Up",
KeepProgress = true,
},
// Disable Attacking Until Animation Ends
new Branch
{
IsAttack = true,
On = 0.5f,
Off = 1.0f,
Signal = Signal.DoAttack,
QueueUntil = 1.0f,
Condition = context => { return PhalanxAttack1Only() == false; },
NextStance = "Sword and Board Punch Attack 2",
NextStanceBlendTime = 0.05f,
},
new Branch
{
IsAttack = true,
On = 0.5f,
Off = 1.0f,
Signal = Signal.DoAttack,
QueueUntil = 1.0f,
Condition = context => { return PhalanxAttack1Only(); },
NextStance = "Sword and Board Punch Attack 1",
NextStanceBlendTime = 0.05f,
},
}
By having structured data like this, I can clearly define what portion of the animation the player can give input - and what timing of the animation the blending to the next attack can occur.
Design your data first 🙂
12 Apr 2017, 20:30
Oh and some terminology:
Signal = button push
On/Off = 0 = beginning of animation, 1.0 = end of animation, 2.0 = end of 2nd loop, etc.
Translation = how much to move (x/y) in relative space