Posted June 17, 2023 by teaminsertnamehere
Author: Charley Weaver
My main goal was to create a spider enemy this week that patrolled, attacked, and alerted other spiders in the area to the player. While the patrolling and attacking were pretty simple to create, the alerting and swarming of the player with spiders proved quite frustrating. One of the most frustrating aspects of this behavior was the animation switching. Seen below, only the enemy initially spotting the player was carrying out the jumping animation at the arrival of the destination of where the player was located at time of spotting. Each spider should be able to jump and attempt to attack the player at each arrival point. This was proving not the case. What I ended up having to do was loop through each enemy, conduct a distance from player check, and indicate if that enemy should be running, walking, or jumping. The initial enemy spotting the player is still the one driving the behavior tree, but the swarming enemies run almost identical code within the "Chase Player" task
I ended up needing to create a distinction of who needed to run the jump, walk, and run animation. This was done by looping through the enemies on the map, and assigning the animation necessary to that particular enemy. While the initial enemy is in charge of the behavior tree, the others run similar code within the "Chase Player" task of the behavior tree.
The result of this distinction allowed for each spider to initiate their own animation sequences. See below: