Game Development Community

AI questions

by Tom Biagioni · in Torque Game Builder · 01/15/2009 (12:32 pm) · 5 replies

well i cant seem to find the AI forums, so i figured i would ask here. Im trying to program some AI for enemys. I want them to wander around, and then when they see the player, they attack. How do i set up a FOV?

#1
01/16/2009 (12:54 am)
Well here's a quick and dirty idea (or two).

This idea revolves the assumption that your camera follows the player around the screen.

If this is the case, what you can do is mount a trigger centered on the player the size of the camera. Have it so that the moment an enemy enters this trigger, it notifies the AI that it can "see" the player and then moves in to attack.

If you don't have the camera following the player, you can set up the triggers on the enemies themselves and have them "see" the player once he steps inside these triggers.

The reason why I say quick and dirty is that having triggers overlapping other objects leads to collision detection issues. Long story short: if you place the object and the trigger that is overlapping the object on the same graph and collision detection group, you can eventually walk through said object. The best workaround I could come up with to fix this issue is to mount a "ghost" object that exists on a different graph group and collision group and assign all triggers to the same graph and collision group. Essentially never let the actual visible objects interact with the triggers specifically.
#2
01/16/2009 (11:27 am)
ah thats a pretty good idea!
#3
01/16/2009 (2:39 pm)
This reminds me. I actually integrated a fuzzy logic library into TGB the other day..... I should post my little TS wrappers. :)
#4
01/17/2009 (12:47 pm)
Another quick and dirty idea:

use the %scenegraph.pickRadius() function and get a radius around the player's position. Check the objects within the radius and if any of them are one of your enemies, you can tell that enemy to attack.

Its kind of like giving the enemy an aggro radius. But it has nothing to do with actual sight. So you player couldn't really hide from the enemy.

But, an idea.
#5
01/18/2009 (8:24 am)
How about this:

1 Each enemy checks to see if the player is within sight distance
2 if in sight check to see if AI is facing the general direction of
the player.
3 if facing the player attack.