UE3 - General Mindless Bot for an unreal mod

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Bjoerninator

New Member
Mar 31, 2009
4
0
0
I'm working on a mod project which calls for an AI controller that just makes the character move along a series of pathnodes and not to react to any other players in any way at all (i.e. not hear or see them or react to being shot by them).

Our plan is to extend the AIController or Controller class rather than the UTBot class, since we're under the impression that the UTBot class is mainly there to tell the bot to react to actions made by other players. We're thinking that we'll only need to use a few functions for the bot to work as we want it to...

One function to find the closest pathnode to the current pathnode that the bot is currently on. This will be our MoveTarget.

Once we've found the closest pathnode, we want the bot to start moving toward the MoveTarget. This requires a MoveToGoal function. Once it has reached the goal, we repeat the GetMoveTarget function in order to find the next pathnode.

Lather, rinse and repeat.

One issue with using only these two function is that the bots might be unable to avoid each other if one of them blocks the path to the target pathnode. During experiments using UTBot we found that the bots were very profficient in passing by one another in order to reach pathnodes. Will this behaviour be eliminated if we mutate the AIController or Controller instead of UTBot?

Purely from a theoretical standpoint, how does our plan sound? We're not experienced UnrealScript programmers so this might be a super obvious question to some of you, but we'd really appreciate some feedback on our way of thinking about our AI. If you have any suggestions on how to simplify or improve things, please share!

Thanks! (We'll probably make another thread on how to make the implementation of the bot efficient and super sweet, since we'll most likely run into some issues when it comes to the coding)
 

Bjoerninator

New Member
Mar 31, 2009
4
0
0
Our first attempt at coding it

Hey dudes, we've been trying to convert our theories into unrealscript, with very limited success... This is basically what we've got so far (just the first attempt and we're still working on it):


Code:
class SanctumCreepAI_Walker extends AIController
	native(AI);
	
var actor NextNode;

function Initialize(const out CharacterInfo BotInfo)
{
	local UTPlayerReplicationInfo PRI;
	local CustomCharData BotCharData;
	
	PRI = UTPlayerReplicationInfo(PlayerReplicationInfo);
	if (PRI != None)
	{
		// If we have no 'based on' char ref, just fill it in with this char. Thing like VoiceClass look at this.
		BotCharData = BotInfo.CharData;
		if(BotCharData.BasedOnCharID == "")
		{
			BotCharData.BasedOnCharID = BotInfo.CharID;
		}

		PRI.SetCharacterData(BotCharData);
	}
	FindNextNode();
}

function FindNextNode()
{
	if (NextNode==none)
	{
		NextNode=FindPathToward(NextNode);
		GotoState('MoveToNode');
	}
}

state MoveToNode
{	
Begin:
	if (Pawn!=none && NextNode!=none)
	{
		MoveToward(NextNode,NextNode);
	}
}

This results in... absolutely nothing. We get a visible pawn, which we don't get if we only use the AIController (that's what our PRI thingie in the initalize function is for). It's not reacting to any player input, such as shooting at it, making noise or running inside its sight radius, which is a good thing as this is the kind of behaviour that we're looking for. The problem is that the pawn isn't moving at all, we don't know if it is that the bot doesnt find the nearby pathnodes or if it's because the MoveToNode is incomplete.

Any help on this is much appreciated!
 
Last edited:

DannyMeister

UT3 Jailbreak Coder
Dec 11, 2002
1,275
1
38
40
Bolivar, Missouri
First of all, you shouldn't have native(AI) in your class declaration, as you aren't writing any native code for SanctumCreepAI_Walker.

Next problem is that you are calling FindPathToward(NextNode) and NextNode is going to be None. That function says it "searches the navigation network for a path to the node closest to the given actor." It's looking for a path node that is close to nothing, which from your experience sounds like it is going to the MoveToNode state with a NextNode that is still None, and nothing will happen.

You need to figure out some way to give your bot a destination. You could try out FindPathTowardNearest() which can give you an actor of a certain class to begin traveling towards. Though once you reach that destination and call the function again, I assume "nearest" is going to be the path node the bot is standing on.