Portal TypeScript start Example?
Someone knows how to spawn a simple AI soldier by code. I found the following code from the official website. So far I can only generate a message when the game starts. But an AI soldier looks impossible:
//This spawns a scriptable AI unit
function OnGameModeStarted() {
mod.SpawnAIFromAISpawner(mod.GetSpawner(1), mod.GetTeam(1));
}
// This is a simple "Follow" behavior that will tell the AI to Stand and Walk to another player's location.
async function simpleAIFollowBehavior(player: mod.Player, target: mod.Player) {
// Set the AI Player's stance to Stand.
mod.AISetStance(player, mod.Stance.Stand);
// Set the AI Player's Move Speed to Walk.
mod.AISetMoveSpeed(player, mod.MoveSpeed.Walk);
// While this AI and the Target player is alive, run this loop which tells the AI to move to the location of the target player.
while (mod.GetSoldierState(player, mod.SoldierStateBool.IsAlive) == true & & mod.GetSoldierState(target, mod.SoldierStateBool.IsAlive) == true) {
// Call the AIMoveToBehavior on the AI Bot player and have it move to the location of the target player.
mod.AIMoveToBehavior(player, mod.GetSoldierState(target, mod.SoldierStateVector.GetPosition));
// Wait for 1 second.
await mod.Wait(1);
}
}
Am I missing infomation? Do I need to setup some basics in the gamemode?? for example spawnpoints...
Thanks,