Description

This sub-system is used to control the behaviour of the Zombie actors when receiving commands from the player.

Blueprints

Untitled

The Return and Attack events are called by the VR_Pawn when the corresponding gesture is performed.

The Return event receives a location from the pawn, which is currently set up in the pawn as a ‘rally point.’ Each zombie then finds a random location around that point, sets the random location as their target location in the blackboard, and then sets their Current Action as Return, both in the actor itself and the blackboard*.* The current action is an enumerator which holds the possible actions for the Zombie, which control the state the Zombie is in.

In the behaviour tree, when the Enumerator is set to Return, the Zombie moves to the rally point set in it’s blackboard. Once it reaches the location, it sets it’s state to Idle using the Behaviour Tree Task SetTaskToWait, and it’s animation to the idle animation. The method of changing it’s animation is detailed in Changing AnimToTexture animations with the Behaviour Tree .

Untitled

Sets current state to ‘Wait’

Sets current state to ‘Wait’

Untitled

When the Attack event is called, it runs the CheckPerceivedEnemies macro.

Untitled

This macro also gets called when the behaviour tree needs a new target. First, it loops through the array of targets that have been perceived. For each entry, it checks to make sure they haven’t been destroyed or killed, and removes them if they have. Once the loop is completed, it checks if there are any perceived targets left. If not, it sets their state to Wait and sets CanSeeTarget to false. **If there are targets remaining, it sets a new attack target.

Untitled

We once again check to make sure the first entry in updated array is still valid, removing it if it isn’t, then we update the CurrentTarget blackboard value as the first enemy in the array, and set CanSeeTarget to true.

Once that macro has completed, we set a location to charge to based on the direction that the player gestured in using the GetChargeLocation function.

Untitled

This function gets a location to run to based on the player’s gesture direction multiplied by the movement range of the zombie. If this location is not navigable, then it reduces the distance by half until a location can be found.

This then gets returned, and set as the blackboard value for TargetLocation. The Zombie’s state is then set to Charge.

Untitled