Scorpion
The Scorpion is one of the most imposing enemies in the game, designed as a tank class enemy. The basic concept that I had when building the scorpion was bullfighting. As such, it's attacks are fast, hard hitting, and force the player to deal with it before anything else. However, it's movement is avoidable with the dodge roll and the many forms of mobility the player has access to.
ShowCase
The Behavior Tree
The scorpion will roam idlily until it has detected the player either through sound or visual detection.
Once the player has been detected, the Scorpion will check if it can reach the player. If it can't, it will hide behind cover until it can.
The default attack will be the charge. This will allow the scorpion to close the distance and do large damage to the player.
When it's off cooldown, the scorpion will use a slower but more precise chase to try and catch the player.
If the player is point blank in front of the scorpion, it will attack using it's pincers.
mechanics
Charge Attack
The Scorpion will shoot a line trace forward and then start moving directly forward.
It will then do the first Charge Check.
If the path to the player isn't completely straight, the charge will not fire off and the scorpion will try to relocate to a position to charge at the player, or will use the chase attack to get closer.
While moving, it will use the event Charge Check to verify it's path. This is for two reasons
The first is to verify if the player is within the turning adjustment range.
This will verify if they player is within a few degrees of the scorpion's current path. If the player is within the range, the Scorpion will adjust it's movement slightly to keep aiming at the player, recalculating the path with Check Player Location in Front.
If the player is too far off the course, the scorpion will then use the Check Location in Front Normal. Both these functions will recalculate the line the scorpion is moving along.
The second reason is to find a suitable stopping point if the scorpion doesn't hit the player.
When the scorpion's line trace hit a wall, it wouldn't land on the nav mesh.
To fix this, I have the Check Location functions shoot a second line trace 75 units long from the wall aimed back at the scorpion that would almost always land on the nav mesh, allowing the scorpion to finish the charge.
If the scorpion's hit detection collides with the player it will attach a hitbox and then transition to the end of the charge.
The End Charge step will reset the behavior tree back to neutral.
End charge will also play an animation montage to give the hit some weight.
Scorpion Chase
Design: The chase attack was designed as a way to add some variety when fighting the Scorpion. It will lock onto the player and chase it, constantly updating it's location. Once it either is in range of the player or after a certain amount of time, it will launch a powerful attack. This chase is slower but more precise then the charge. This gives the player a chance to shoot at the scorpion but keeps the player moving.
Damage: 40
Speed: Up to 450 units per second
Frequency: Low
Code:
Sets state booleans, changes speed, and activates the Smart Move function that all creatures have.
The Scorpion then enters a loop where it will check if the player has entered the sting range.
During this loop the scorpion will chase the player. If the player hasn't entered the range, it will decrease the counter.
If the player is in range, or the counter reaches 0, the scorpion will move onto the attack phase.
The scorpion will then check to see if it is alive before stopping all movement, setting the speed to 0, and disabling it's rotation.
It will then play the attack animation montage which has the hitbox built into it.
After the animation has finished it will reset the blackboard variables so the scorpion can then move onto the next attack.