VendorX- Pawn code:
Code:
class StealthPawn_Test extends UTPawn
placeable;
defaultproperties
{
ControllerClass=class'AI.StealthBot_Test'
SightRadius=+1600.0
PeripheralVision=+45.0
GroundSpeed=350.0
}
Bot code:
Code:
class StealthBot_Test extends AIController;
var Vector TempDest;
var float EnemyDistance;
simulated event Possess(Pawn inPawn, bool bVehicleTransition)
{
super.Possess(inPawn, bVehicleTransition);
Pawn.SetMovementPhysics();
}
auto state Idle
{
event SeePlayer (Pawn Seen)
{
super.SeePlayer(Seen);
Enemy = Seen;
EnemyDistance = VSize ( Pawn.location - Enemy.location );
if( EnemyDistance < 200 )
GotoState('Chase');
}
Begin:
}
state Chase
{
ignores SeePlayer;
function bool FindNavMeshPath()
{
NavigationHandle.PathConstraintList = none;
NavigationHandle.PathGoalList = none;
class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle, Enemy );
return NavigationHandle.FindPath();
}
Begin:
EnemyDistance = VSize( Pawn.location - Enemy.location );
if( EnemyDistance < 200 )
{
GotoState('Shoot');
}
else if( NavigationHandle.ActorReachable( Enemy ) )
{
MoveToward( Enemy,Enemy, 100 );
}
else if( FindNavMeshPath() )
{
NavigationHandle.SetFinalDestination(Enemy.Location);
NavigationHandle.DrawPathCache(,TRUE);
if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) )
{
DrawDebugLine(Pawn.Location,TempDest,0,255,0,true);
DrawDebugSphere(TempDest,16,20,0,255,0,true);
MoveTo( TempDest, Enemy );
}
}
else
{
GotoState('Idle');
}
goto 'Begin';
}
state Shoot
{
Begin:
Sleep(1.0);
GotoState('Idle');
}
Defaultproperties
{
}
Edit: I was going to list the specifications for how I placed the actors in my level, and found that 'force deathmatch ai' was checked. I unchecked it and found that two of the four pawns stayed in place, even with active path nodes in the environment. The other two moved, but only a short distance. However, they are all facing straight down by default, not useful if I want them surveying for the player. Also, I am spawning the pawns via kismet in a VCTF game.
Bookmarks