
Originally Posted by
Solid Snake
How are you doing path finding, show us the code please. It is likely that you are printing out the debugging stuff...
thx for your reply Solid snake, here it is the code..
Code:
class TKOVMonsterControler extends AIController;
var Actor target;
var() Vector TempDest;
event Possess(Pawn inPawn, bool bVehicleTransition)
{
super.Possess(inPawn, bVehicleTransition);
Pawn.SetMovementPhysics();
}
//I'm adding an default idle state so the Pawn doesn't try to follow a player that doesn' exist yet.
auto state Idle
{
event SeePlayer (Pawn Seen)
{
super.SeePlayer(Seen);
target = Seen;
GotoState('Follow');
}
Begin:
}
state Follow
{
ignores SeePlayer;
function bool FindNavMeshPath()
{
// Clear cache and constraints (ignore recycling for the moment)
NavigationHandle.PathConstraintList = none;
NavigationHandle.PathGoalList = none;
// Create constraints
class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle,target );
class'NavMeshGoal_At'.static.AtActor( NavigationHandle, target,32 );
// Find path
return NavigationHandle.FindPath();
}
Begin:
if( NavigationHandle.ActorReachable( target) )
{
FlushPersistentDebugLines();
//Direct move
MoveToward( target,target );
GotoState('Shoot'); //Start shooting when close enough to the player.
}
else if( FindNavMeshPath() )
{
NavigationHandle.SetFinalDestination(target.Location);
FlushPersistentDebugLines();
NavigationHandle.DrawPathCache(,TRUE);
// move to the first node on the path
if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) )
{
DrawDebugLine(Pawn.Location,TempDest,255,0,0,true);
DrawDebugSphere(TempDest,16,20,255,0,0,true);
MoveTo( TempDest, target );
GotoState('Shoot');
}
GotoState('Shoot'); //Start shooting when close enough to the player.
}
else
{
Sleep(0.5);
//We can't follow, so get the hell out of this state, otherwise we'll enter an infinite loop.
GotoState('Idle');
}
goto 'Begin';
}
simulated event GetPlayerViewPoint(out vector out_Location, out Rotator out_Rotation)
{
// AI does things from the Pawn
if (Pawn != None)
{
out_Location = Pawn.Location;
out_Rotation = Rotation; //That's what we've changed
}
else
{
Super.GetPlayerViewPoint(out_Location, out_Rotation);
}
}
state Shoot
{
Begin:
Pawn.StartFire(1);
Sleep(0.3);
GotoState('Idle');
}
DefaultProperties
{
}
Bookmarks