I have a problem. I am currently making a gamemode which involves buildings producing units which automatically attacks the enemy. My problem is that the AIMODE_GOTO and AIMODE_BRAINHUNT lags horribly. My 250 fps drops to 10 for a sec when AIMODE_GOTO is set by lua. When i remove the AIMODE_GOTO from my code, the lag is completely gone.
Anybody got some smart tricks to avoid it. I don't think I've had the lag in skirmish defense and anyother mode where the enemy comes by dropships.
Here is the code where I use the AI_GOTO
Code:
function Battlegrounds:Teleport(from , to , actor)
--Teleport the actor.
actor.Pos = to;
actor.Vel.Y = 0;
--Make the actor glow for a while.
actor:FlashWhite(1500);
--Create the teleportation effect for both teleporters in the set.
local fxa = CreateAEmitter("Teleporter Effect A");
fxa.Pos = from;
MovableMan:AddParticle(fxa);
local fxb = CreateAEmitter("Teleporter Effect B");
fxb.Pos = to;
MovableMan:AddParticle(fxb);
actor.AIMode = Actor.AIMODE_GOTO;
actor:ClearAIWaypoints();
if actor.Team == 0 then
actor:AddAISceneWaypoint(Vector(4128, 876));
else
actor:AddAISceneWaypoint(Vector(120, 876));
end
end