Game Development Community

Collision Detection for only AI Bots

by DALO · in Torque Game Engine · 01/13/2009 (7:58 am) · 4 replies

I have managed to get the AI in my game working.....decent. There is quite a bit of lag however when I'm in a level with lot's of edges and pits.....those darn bot's fall off when bumped or nudged. Whenever my bots fall off they have to reset, respawn and get new goals. If they fall off over and over then I get some nasty chuggage. Is it possible to create a dts object that is transparent, give it a unique name in the game, and somehow enable the collision for AI bots only?
I'm assuming that this would be in the player class.....?....but where? and how to single out objects?
This would be faaaaantastic if someone could shed some light.
Thx.

#1
01/13/2009 (9:00 am)
Have you considered using a trigger? Create a trigger and call it PitOfDeath then try something along these lines (untested):
function PitOfDeath::onEnter(%this, %object)
{
     %objectDB = %object.getDatablock();
     %objectClass = %objectDB.Class;

     if(%objectClass = "AI")
     {
          //Do what you want to do here

          %object.SetPosition("X Y Z");
     }
}

If respawning is too expensive, perhaps just moving them somewhere outside of the player's view and keeping their their goals, etc.

'Patrick
#2
01/13/2009 (9:37 am)
Yeah, I have thought of that. The one thing I'm concerned with is that we have a few levels where we would have to put a very large number of triggers all of which would would have to do a bunch of math calculations. With the dts objects it there would be no math to perform and no trigger checks for all triggers. Would a vast amount of triggers cause slow down?
#3
01/13/2009 (9:44 am)
From what I understand, collisions kill performance much more than triggers because a collision has to calculate where the collision object will be ahead of time to prevent the objects from penetrating one another. I could be mistaken.
#4
01/13/2009 (10:34 am)
One way you might consider doing this is by defining a typemask for AICollidableObjectType or something like that. Then you just set that typemask in things you want the AI to collide against, and when your AIs move, add this mask to their collision mask. For more information, look up objectTypes.h, sCollisionMoveMask in player.cc, and Afrim Kacaj's climbable objects resource (which implements a ClimbableItemObjectType - you'll need to pretty much follow the method he uses to make objects climbable).
The tricky thing will be including the ai collision typeask in movement mask checks, since all these are done in the Player class, rather than AIPlayer. You'd probably have to find every use of sCollisionMoveMask (or its client-side equivalent) and if the Player happens to be ai-controlled, add the ai collision mask.
The downside to this, of course, is that mask bits are limited in number. You could just hijack the existing AIObjectMask, since it doesn't seem to be used for much useful.