Follow Me:AI Leads Player
written by Fidcal
This is a method to get an AI to come to the player and lead him/her to a selected spot with speech. So an innkeeper might take you to your room or a guide lead you to a treasure cave through the woods, etc.
This tutorial is provisional and incomplete: the AI is frozen in the crucifix position at start so must start off-screen and I have put in the Doom sentry robotic squeaks for the voice for now. Later this should be improved upon but it does work as is and you can always not add the speech to make the AI dumb.
Beginners should have first read Dark Radiant Must Know Basic Intro and have basic knowledge of Dark Radiant.
You should also know how to set up an AI to patrol. If not, see AI Patrols, Walking Routes
- Create the AI who is to lead the player.
- Set it up to patrol from, along, and to, various path_corners to where you want the player to be lead.
- Add to the AI these properties : values...
- scriptobject : char_sentry
- lead_player : 1
- Then optionally add these robotic squeaks (not needed for dumb or for testing but you can see how to add different speeches.)
- snd_waiting_for_player : char_sentry_waiting_for_player
- snd_cant_reach_player : char_sentry_cant_reach_player
- snd_target_lost : char_sentry_target_lost
The above uses a vicinity trigger so when the player reaches a certain place in the mission it will trigger the AI to come to the player (from wherever you like so long as it can reach the player or start it near the trigger.)..
- Create or use a handy brush where you want the AI to meet the player. Use nodraw texture if you don't want it visible else anything will do - a post or whatever.
- With it selected, create entity : trigger_once
- To the entity add the property : Target with the value being the name of the AI who is to lead the player.
Try it out in-game by walking to the trigger position. The AI should come to you then head for the first patrol point on his route and so on to the final one but it should stop and come back to the player if you hold back too far or get lost.