Tegleg Records

Tegleg Records
Tegleg Records

Friday, 3 June 2011

udk random movement ai code

heres an ai that moves around randomly

class RandomAI extends GameAIController;

var Vector MyTarget;

simulated event PostBeginPlay()
{
super.PostBeginPlay();

//start the brain going at half second intervals
SetTimer(0.5, true, 'BrainTimer');
}

function BrainTimer()
{
local int OffsetX;
local int OffsetY;

//make a random offset, some distance away
OffsetX = Rand(500)-Rand(500);
OffsetY = Rand(500)-Rand(500);

//some distance left or right and some distance in front or behind
MyTarget.X = Pawn.Location.X + OffsetX;
MyTarget.Y = Pawn.Location.Y + OffsetY;
//so it doesnt fly up n down
MyTarget.Z = Pawn.Location.Z;

GoToState('MoveAbout');

}

state MoveAbout
{
Begin:

MoveTo(MyTarget);
}

defaultproperties
{

}

No comments:

Post a Comment

Loading...