Game Development Community

AI Trigger discussion

by Jesse P · in General Discussion · 05/28/2008 (4:53 pm) · 1 replies

I've got an AI bot (killer kork) and I need to figure out how to set triggers around the level to spawn bots when the player enters the various triggers. The reason I need this is because as is the killer kork AI script is killing performance. I'm a novice at torque script but learning and getting much better so I'd like to start this discussion. Thanks.

Right now as it is the script I have spawns one bot at each path marker I place on the map.

Need to make it so each trigger triggers a bot to spawn at specific markers

#1
05/28/2008 (6:33 pm)
If you haven't read up on triggers in the documentation and on TDN now is the time to do so.
Also check out the basics of Torque Development list

There's a thread explaining how to make sure only the player sets off a trigger (and not the AI) Here

To spawn a bot with script look through your AiPlayer.cs (or whatever you're using as an ai script) and look for your AiPlayer::Spawn function - that gives you all the stuff/variables. In your trigger script try something like:

%player = new AIPlayer(badguy) {datablock = "demoplayer"; position = mymarker.getposition();};

(badguy) is just the name of the AI that will spawn (you don't need one if you don't want one), and mymarker is whatever you called your marker (named in the editor when you create it).

Each time the player goes through the trigger it'll spawn an AI at the named position - at least that's the theory.

You might have to jiggle the script a bit to get it to work with your own files. Searching the word "spawn" through your AIplayer.cs is a good way of seeing how all the functions call each other.