Hyper Knights: Battles

Hyper Knights: Battles

Not enough ratings
Create Custom AI - AoE Knockback
By Endless Loop Studios
In this guide you will learn how to add a Custom AoE Knockback ability to your Unit
   
Award
Favorite
Favorited
Unfavorite
Intro
In this guide you will learn how to add a Custom AoE Knockback ability to your Unit.
When there are multiple enemies around this Unit, it will do a Ground Pound Animation causing enemies in range to be knocked back and stunned.
Animation
First we're going to make the Ground Pound Animation
When the fists hit the ground we're going to add the trigger 'TRIGGER'.
This is the Keyframe that will trigger the Action where the enemies will be knocked back



Animation Type
Now that we have the Animation lets go into the Animation Type Builder
Create new Animation Type named GroundPound
Since the direction is not relevant we're going to add our Animation to all Directions
Save the Animation Type



Okay so now we have an Animation Type which contains our Ground Pound Animation
Custom AI
Go into the Unit Builder
Create a new Unit (or load one you previously made), select the Sprite Sheet and give it a name

Let's add our Ground Pound as an Animated Action




Set the Cooldown to 6 seconds
Set the Animation to our newly created Ground Pound Animation Type
We used the default trigger 'TRIGGER' in our Animation so leave it as it is
Logic Priority 100 is enough to cancel the normal attack (which has a default Logic Priority of 90)


Now let's create a Condition of type 'Has Target Amount in Range'
Name it GroundPoundCondition
For the Range set 50 and for the Amount set 5
This means this Condition will be True when there are 5 or more enemies within a distance of 50


Go back into the Ground Pound Animated Action and set the Condition to our new Condition



Now let's make the Code Block that will be executed when the Animation hits the trigger

Create a new Code Block and name it GroundPoundKnockback
In order to knockback we have to get a list of all the enemies in range
Click 'Add Code Action' and select 'Get Target List'




We need a Variable to place the returning result of this Code Action
Create a Variable of type Object List and name it KnocbackTargetList


Now set that Variable as the parameter for Return: Target List


Okay so now we have a list of all the enemies we want to knock back, add the Code Action 'Target List Knockback Slide'
Set our Variable as the parameter 'Target Object List'


Now we need to make a Code Block that will stun these units when they finish the knockback slide animation
Create a new Code Block named KnockbackListStun
Add Code Action 'Target List Stun'
Select the Variable KnockbackTargetList
Go back to the GroundPoundKnockback Code Block
Select the Code Action 'TargetListKnockbackSlide'
Set the parameter 'On Knockback Slide Complete' to our new Code Block
And now just for fun add the Code Action 'Shake Camera'


Click 'Save' and go try your new Unit in the Sandbox.



Congratulations! You have built your own AI!


Now you can see how by using the various Code Actions along with your own Animations you can build anything you can think of!

Once you have made a really cool Unit with some really interesting AI you can Upload it to the Workshop so other people can play with it.

Your imagination is the limit! Go forth and make something awesome!