Game Development Community

AI Markers

by Randy Hearn - Magnum · in Torque Game Engine Advanced · 04/24/2009 (10:38 pm) · 3 replies

For the past couple of weeks every chance I get I have been playing around with trying to spawn my AI players without using AI Markers. Had some marginal success but a few hiccups here and there when in the editor.

Has anyone found an alternative way to place AI bots without using AI Markers? Or is that the still the best approach.

My recent attempts were to simply place the AI BOT in the editor, but their think cycle would stop when the editor was active. My problem was successfully re-starting all of the bots when I closed the editor.

Then again it may be totally different in T3D, but still interested in the different approaches to spawning AI.

About the author

Technical Product Designer (Mechanical Design) for Boeing for over 25 years working with CAD and PLM systems. I have a Associates Degree in Business and a partial B.S. in Game and Simulation, just couldn't see paying the costs for some of the classes.


#1
04/25/2009 (1:05 am)
Trying to use the editor to place NPCs directly can be a big exercise in frustration.

I'm not really familiar with the "AI Marker", but what I use is a Spawn Zone, which is somewhat similar to a physical zone, but the NPC will spawn at an appropriate place within that zone based upon conditions. i.e. it will try to avoid spawning too close to or inside of other objects within that zone.

Then I associate a goal set with the spawn zone, which the NPC will use. This way I can interchange different NPCs and they'll follow the same goals in their own way.
#2
04/25/2009 (5:37 am)
I wrote my own spawn function, similar to Quake style games. It's idea is trigger based though you can run a script at startup with the spawns listed. Player walks into trigger, AI spawn at a location. I use waypoint markers just to get the XYZ of that location.

The function is something like:
function AIPlayer::dospawn(%name, %aitype, %spawnPoint)
{
	if(isObject(%spawnPoint))
	{
  %player = new AIPlayer(%name) {
    dataBlock = %aitype;
	};
  
  MissionCleanup.add(%player);
  %player.setTransform(%spawnPoint.gettransform());
%player.schedule(%startup, think);
  return %player;

			}
			else
			{
			echo("not a legit spawnpoint - do bugger all");
			}
}

And the call is like:
//AIPlayer::dospawn(%name, %aitype, %spawnPoint)
%aiplayer = AIPlayer::dospawn(my_bot, bot_type, waypointx);
#3
04/25/2009 (7:55 am)
@Gerald,

The AI Marker is basically just a spawn marker or icon if you will placed in the editor, which holds the spawn location. Sounds like would be the same thing as a trigger or spawn zone. So sounds like the general idea is to have something that holds the location rather than the player itself. For me I had planned on placing an attribute on the marker which represents a spawn radius and then do the check you mention. That way each NPC can be spawned in a more random fashion.
I may need to look at zones as well, to keep them from spawning outside of a room. I even considered adding second markers as alternate spawn locations and just leaving the radius to zero to provide more accurate spawning when needed.



@Steve,

Thanks for the info. I am basically doing the same span method, just without zones or triggers. I can give you a little hint as to why I am not in favor of zones (for now). Say I have a sniper or spotter that is on a hilltop. He needs to see every NPC in the range that he can actually see. the NPCs will all be actively doing whatever it is they are supposed to be doing. Another group of players will be clearing the streets. If I am using a zone or triggers, the players could be in two different zones, which means an NPC could spawn in front of my clearing players and the spotter/sniper would never see them. Sooo.. For now I am playing with different ideas on that, seems my whole level would be the zone in this case...


But you both have basically answered my problem for now. I should spawn some sort of marker or icon in the game, then when the game runs, spawn the player in that based on some sort of player location/action.


Thanks for the info.