I'm working on an AI engine for my game and I want the enemy to only move towards the player when it can see it, I have heared of line of sight and I think it is exactly what I need. Could someone give me an example of how to use it?
Printable View
I'm working on an AI engine for my game and I want the enemy to only move towards the player when it can see it, I have heared of line of sight and I think it is exactly what I need. Could someone give me an example of how to use it?
You would need to use the Advanced Direction Object, and compare the distance between the player and enemies. Then run a loop to make sure that there are no obstacles between the player and the enemy.
stephen1980
im confused how does the loop tell if there are obstacles?
A simple reverse method, maybe, would be have your enemy shoot a detector towards the character, and if it hits the character, have the enemy attack. I know that is an older method, but works.
Marv
Theres also a tut on the dailyclick somewhere about the "last" line of sight method. It's very good. I can't provide a link :(
Here are a few interesting articles describing Line of Sight further:
http://www.create-games.com/article.asp?id=1761
http://www.create-games.com/article.asp?id=1620
http://www.create-games.com/download.asp?id=7524