Hello all,
I'm currently having a problem with the States in my custom bot. My hope is the have the bot patrolling around, going from one path node to the next, until it sees the player. Once it sees the player, it switches over to the NavMesh for navigation. The NavMesh code is working perfectly fine, the problem I'm running into is having it patrol around on its own in the beginning. Here's the code I currently have:
I've placed the log entries in the code to try and make sure that the code is being run. However, in the logs all I ever see are "BEGIN STATE CHASE" and "FindNavMeshPath returned TRUE." None of the others seem to be output to the log. I don't understand how that's possible if the rest of it runs as expected.Code:/** * PotatoChipController * * Creation date: 27/02/2012 20:24 * Copyright 2012, Jay */ class PotatoChipController extends AIController; var Actor Player; var Vector TempDest; var float playerDistance; var int TimesShot; var int ChaseTimer; defaultproperties { } simulated event Possess(Pawn inPawn, bool bVehicleTransition) { super.Possess(inPawn, bVehicleTransition); // Important or bot will not move Pawn.SetMovementPhysics(); } // Starting State, watch for player auto state Idle { event SeePlayer (Pawn Seen) { `log("I SEE THE PLAYER"); // Call AIControllers SeePlayer function super.SeePlayer(Seen); Player = Seen; TimesShot = 0; ChaseTimer = 0; // Get distance to player playerDistance = VSize( Pawn.location - Player.location ); // If within 200 units start shooting at player, otherwise give chase if( playerDistance < 200 ) { GotoState('Shoot'); } else { GotoState('Chase'); } } Begin: `log("Attempting to find Path Node at Start"); MoveTo(FindRandomDest().Location); } // Chases the player using direct movetoward if player is reachable and pathfinding if not state Chase { ignores SeePlayer; // Gets the navmesh path to the player function bool FindNavMeshPath() { // Clear cache and constraints (ignore recycling for the moment) NavigationHandle.PathConstraintList = none; NavigationHandle.PathGoalList = none; NavigationHandle.bDebugConstraintsAndGoalEvals = true; // BAD DON'T USE UNTIL FIXED BY EPIC //NavigationHandle.bUltraVerbosePathDebugging = true; // Create constraints class'NavMeshPath_Toward'.static.TowardGoal( NavigationHandle, Player ); class'NavMeshGoal_At'.static.AtActor( NavigationHandle, Player, 25 ); // Find path return NavigationHandle.FindPath(); } Begin: `log("BEGIN STATE CHASE"); Player = GetALocalPlayerController().Pawn; // Check if the player is within firing range playerDistance = VSize( Pawn.location - Player.location ); if(ChaseTimer > 0) { ChaseTimer -= 1; } // Give up if player is farther than 2000 units away if( playerDistance > 2000 ) { GotoState('Idle'); } // If player is between 400 and 1000 chase timer is equal to 0 start shooting if( playerDistance > 400 && playerDistance < 1000 && ChaseTimer == 0) { //GotoState('Shoot'); } // There is a direct path available to the player if( NavigationHandle.ActorReachable( Player ) ) { //FlushPersistentDebugLines(); /* The player is reachable so move towards him Focus on the player Offset destination by 100 */ Pawn.StartFire(0); /* COMMENT THIS TO INCREASE FIRING SPEED */ Pawn.StopFire(0); MoveToward( Player,Player, 100 ); } // No direct path to player, use navmesh to find else if( FindNavMeshPath() ) { `log("FindNavMeshPath returned TRUE"); Pawn.StartFire(0); /* COMMENT THIS TO INCREASE FIRING SPEED */ Pawn.StopFire(0); // The player is not reachable so use the navmesh path to move towards him // Set the ultimate destination to the players location NavigationHandle.SetFinalDestination(Player.Location); // Debug info //FlushPersistentDebugLines(); //NavigationHandle.DrawPathCache(,TRUE); //NavigationHandle.PrintPathCacheDebugText(); /* TempDest is passed in by reference, is set to next location to move to Stay outside of Pawns Collision Radius */ if( NavigationHandle.GetNextMoveLocation( TempDest, Pawn.GetCollisionRadius()) ) { /* Draws a line from the Pawns current location to the TempDest (proposed players location) Draws a sphere at the proposed players location Moves to destination */ //DrawDebugLine(Pawn.Location,TempDest,0,255,0,true); //DrawDebugSphere(TempDest,16,20,0,255,0,true); MoveTo( TempDest, Player ); } } else { // We can't get to the player so just go back to being Idle MoveTo(FindRandomDest().Location); `log("--------------------Attempting to find Path Node--------------------------"); //GotoState('IdleAgain'); } goto 'Begin'; } // Stop and fire at the player state Shoot { ignores SeePlayer; Begin: Player = GetALocalPlayerController().Pawn; `log("OPEN FIRE"); // Stop pawn from moving Pawn.ZeroMovementVariables(); Sleep(1); Pawn.StartFire(0); /* COMMENT THIS TO INCREASE FIRING SPEED */ Pawn.StopFire(0); TimesShot += 1; // If the player is too far away go back to Idle playerDistance = VSize( Pawn.location - Player.location ); // If the player is too close, or too far too shoot, or we've shot 10 times already give chase again if( playerDistance < 400 || playerDistance > 1000 || TimesShot > 10) { ChaseTimer = 5; GotoState('Chase'); } goto 'Begin'; }
Any help is appreciated as always.Here's some of the log:
Code:[0015.18] ScriptLog: Player restarted [0015.18] ScriptLog: START MATCH [0015.18] Log: GFxMoviePlayer::Start called with no movie loaded [0015.18] ScriptWarning: Accessed None 'OnlineSub' UDNPlayerController UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPlayerController_0 Function UTGame.UTPlayerController:ClientSetOnlineStatus:0033 [0015.18] ScriptWarning: Accessed None 'OnlineSub' UDNPlayerController UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPlayerController_0 Function UTGame.UTPlayerController:ClientSetOnlineStatus:02D1 [0015.18] ScriptWarning: Accessed None UDNPlayerController UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPlayerController_0 Function UTGame.UTPlayerController:ClientSetOnlineStatus:02E5 [0015.18] Log: PIE: play in editor start time for UEDPIEUDN-GlowingLevel 0.272 [0015.18] ScriptWarning: Player WhatToDoNext with no pawn UTBot UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTBot_0 Function UTGame.UTBot:WhatToDoNext:0068 [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UTWeap_LinkGun UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTWeap_LinkGun_0 Function UTGame.UTWeapon:SetupArmsAnim:004C [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UTWeap_LinkGun UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTWeap_LinkGun_0 Function UTGame.UTWeapon:SetupArmsAnim:0160 [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UTWeap_LinkGun UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTWeap_LinkGun_0 Function UTGame.UTWeapon:SetupArmsAnim:0197 [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UTWeap_LinkGun UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTWeap_LinkGun_0 Function UTGame.UTWeapon:AttachWeaponTo:01AE [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UTWeap_LinkGun UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UTWeap_LinkGun_0 Function UTGame.UTWeapon:AttachWeaponTo:01E5 [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:00B0 [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:00EF [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:012E [0015.23] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:016D [0021.64] ScriptLog: BEGIN STATE CHASE [0022.59] ScriptLog: BEGIN STATE CHASE [0023.55] ScriptLog: BEGIN STATE CHASE [0024.50] ScriptLog: BEGIN STATE CHASE [0025.44] ScriptLog: BEGIN STATE CHASE [0026.40] ScriptLog: BEGIN STATE CHASE [0027.37] ScriptLog: BEGIN STATE CHASE [0028.32] ScriptLog: BEGIN STATE CHASE [0029.29] ScriptLog: BEGIN STATE CHASE [0030.24] ScriptLog: BEGIN STATE CHASE [0032.78] ScriptLog: BEGIN STATE CHASE [0033.72] ScriptLog: BEGIN STATE CHASE [0034.68] ScriptLog: BEGIN STATE CHASE [0035.64] ScriptLog: BEGIN STATE CHASE [0036.60] ScriptLog: BEGIN STATE CHASE [0038.37] ScriptLog: BEGIN STATE CHASE [0039.32] ScriptLog: BEGIN STATE CHASE [0040.28] ScriptLog: BEGIN STATE CHASE [0041.23] ScriptLog: BEGIN STATE CHASE [0042.19] ScriptLog: BEGIN STATE CHASE [0043.15] ScriptLog: BEGIN STATE CHASE [0043.49] ScriptWarning: Divide by zero UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function Engine.Pawn:TakeFallingDamage:0116 [0048.89] ScriptLog: BEGIN STATE CHASE [0049.61] ScriptLog: BEGIN STATE CHASE [0049.63] ScriptLog: BEGIN STATE CHASE [0049.65] ScriptLog: BEGIN STATE CHASE [0049.67] ScriptLog: BEGIN STATE CHASE [0049.68] ScriptLog: BEGIN STATE CHASE [0049.70] ScriptLog: BEGIN STATE CHASE [0049.72] ScriptLog: BEGIN STATE CHASE [0049.74] ScriptLog: BEGIN STATE CHASE [0049.75] ScriptLog: BEGIN STATE CHASE [0049.77] ScriptLog: BEGIN STATE CHASE [0049.79] ScriptLog: BEGIN STATE CHASE [0049.81] ScriptLog: BEGIN STATE CHASE [0049.83] ScriptLog: BEGIN STATE CHASE [0050.99] ScriptLog: BEGIN STATE CHASE [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNWeap_RollingPin UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNWeap_RollingPin_0 Function UTGame.UTWeapon:SetupArmsAnim:004C [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNWeap_RollingPin UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNWeap_RollingPin_0 Function UTGame.UTWeapon:SetupArmsAnim:0160 [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNWeap_RollingPin UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNWeap_RollingPin_0 Function UTGame.UTWeapon:SetupArmsAnim:0197 [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNWeap_RollingPin UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNWeap_RollingPin_0 Function UTGame.UTWeapon:AttachWeaponTo:01AE [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNWeap_RollingPin UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNWeap_RollingPin_0 Function UTGame.UTWeapon:AttachWeaponTo:01E5 [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:00B0 [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:00EF [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:012E [0051.99] ScriptWarning: Accessed None 'ArmsMesh' UDNPawn UEDPIEUDN-GlowingLevel.TheWorld:PersistentLevel.UDNPawn_0 Function UTGame.UTPawn:WeaponChanged:016D [0052.15] ScriptLog: BEGIN STATE CHASE [0053.31] ScriptLog: BEGIN STATE CHASE [0053.31] Log: ------- PATH CONSTRAINT STATS -------- [0053.31] Log: Processed: 75 ThrownOut: 0 (0.00% thrown out) AddedPathCost: 0.00 (0.00% total) AddedHeuristic: 417.00 (100.00% total) - (NavMeshPath_Toward_0) [0053.31] Log: -------------------------------------- [0053.31] Log: TotalThrownOut: 0 TotalAddedDirectCost: 0.00 TotalAddedHeuristicCost: 417.00 [0053.31] Log: ------- GOAL EVALUATOR STATS -------- [0053.31] Log: Threw Out 22 (out of 23 processed (95.65%)) (Responsible for 100.00% of all nodes thrown out) - NavMeshGoal_At_0 [0053.31] Log: --------------------------------------- [0053.31] ScriptLog: FindNavMeshPath returned TRUE [0053.57] ScriptLog: BEGIN STATE CHASE [0053.57] Log: ------- PATH CONSTRAINT STATS -------- [0053.57] Log: Processed: 92 ThrownOut: 0 (0.00% thrown out) AddedPathCost: 0.00 (0.00% total) AddedHeuristic: 392.00 (100.00% total) - (NavMeshPath_Toward_0) [0053.57] Log: -------------------------------------- [0053.57] Log: TotalThrownOut: 0 TotalAddedDirectCost: 0.00 TotalAddedHeuristicCost: 392.00 [0053.57] Log: ------- GOAL EVALUATOR STATS -------- [0053.57] Log: Threw Out 26 (out of 27 processed (96.30%)) (Responsible for 100.00% of all nodes thrown out) - NavMeshGoal_At_0 [0053.57] Log: --------------------------------------- [0053.57] ScriptLog: FindNavMeshPath returned TRUE [0053.81] ScriptLog: BEGIN STATE CHASE



Here's some of the log:
Reply With Quote


Bookmarks