AI Follow Player

Last modified by KDearnley on 2023/07/31 14:06

To create a demon companion, you'll need to convince an AI to follow you around.

The reference map HUF4XDPB (Reference: Keep AI at Path Point) shows an example of a peaceful AI companion that will follow a player around the map.

Use Trigger Areas to Simulate a Following AI

This method breaks the map into zones. When a player enters a zone, the AI companion will be instructed to follow a point at the center of the zone.



Create a trigger volume that covers the area of the zone. A larger zone will use fewer network objects, but the zone should be small enough to convincingly simulate the desired AI behavior.

AIFollowZone.PNG


Use a repeater and single path point to keep an AI stationary. Add a repeater that starts when the player enters the trigger zone, and stops when the player exits the zone.

AIFollowRepeater.PNG


Add a Path Point inside the zone. You can optionally increase the Radius property on the AI Path Point so that it's not as obvious that the AI is running to a discrete point instead of following the player. In this example, the Radius is set to 328. The Cached Object is set to the AI so that the activator can be changed from player to demon.

AIFollowPathPoint.PNG


The repeater will tell the AI to follow the path once every second. This will make it appear as though the AI is standing still, waiting for the player to move before following the player into another zone.


Duplicate the zone to fill the map or path.

AIFollowPlayer.PNG


The above pattern will continually interrupt the companion AI, preventing it from attacking if enemies are present. To make an attacking companion, use the two-point loop of Path Points described on the AI_Movement basics page to make an AI stand still instead of the repeater method. Set at least one of the two Path Points to Unfollow for Combat to allow the AI to attack nearby enemies. This alternate method will make your AI companion prioritize following the player into a zone, but will attack enemies as long as the player stays in the current zone.

Tags: Patterns