Object-Avoiding Follower AI
Author: | DeadmanDines
|
Submitted: | 26th November, 2007
|
Favourites: | 0 |
Genre: | Tutorial
| Downloads: | 596
|
Rated: |
|
|
Does what it says on the tin.
Two frames, one is a basic example, the second is a complex maze. The little NPC character will follow you no matter where you go.
1st Example
A small square, you walk around the square, and the NPC will follow you. It draws two lines to show the Line of Sight processes that are running.
2nd Example
Maze. The NPC will follow you through the maze. In addition to the features from example 1, you can retrace your steps and 'undo' the path you have laid. This way if the NPC is a long way behind, and you decide you've taken a wrong turning and go somewhere else, the NPC won't imitate your mistake.
This one has better comments.
How it Works
If the NPC can see you, he enters a DIRECT state, where he will just follow your coordinates.
If he cannot see you, he goes into INDIRECT state. The moment his line of sight with you ends, a small marker is placed at the point where the LOS colided with the wall. That marker is then moved away from the wall to give more following space.
From then on, future Line of sight tests are made, not between the player and the NPC, but between the player and the newest Marker.
When these LOS tests fail, another marker is made as before, and the result is a Breadcrumbs-esque engine.
If at any time the NPC can see you again, all Markers are eradicated. They are also destroyed as the NPC 'gobbles them up'.
I found it works surprisingly well.
Limits
Only works for one follower.
Review This Download
http://chris.planetabeo.com/Upload/tut_follower.zip (21 kb )
|
|
DeadmanDinesBest Article Writer Registered 27/04/2006
Points 4758
Is this worth a look? Let others know! Favourite
|