Moving a bot to a vector

  • 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.

redeemer90

New Member
Oct 7, 2004
4
0
0
Hi,

I have been trying to get a bot to move to a vector for the last 8 hours, but have failed. Firtly, I tried to make a Mutator

Code:
function Timer()
{
    local Controller C;
    local Bot b;
    local vector R;
	
	R.x = 957;
	R.y = -859;
	R.z = -947;
		

    for (C = Level.ControllerList; C != None; C = C.NextController)
    {
	
	
        if (C.bIsPlayer)
        {
		
		b = Bot(C);
		if (b == None)
			return;
			
		HumanActor = b.FindPathTo(R);
			
		if (b.ActorReachable(HumanActor))
		{
			Log (b.Name$" Reachable");
			b.RouteGoal = HumanActor;
			b.RouteCache[0] = None;
			b.GoalString = b$"almost at "$HumanActor;
			b.MoveTarget = HumanActor;
			b.bFinalStretch = true;
			b.SetAttractionState();
		}
		else
		{
			Log ("Dest not reachable");
		}
	}
			
	b.Destination = R;
	b.SetAttractionState();
    }

}
PS: I have tried several different variations of this code, but none seem to work.

where HumanActor is a var class HumanActor;
Then I tried to make my own gametype and overrode the method when a player way called. I was also writing stuff to the log file from there. That way, I know it was being called, but unfortunately, my bots were still not budging.

Another thing that I tried is to call the FindPathTo function and then MoveToward, but when I do this I get a compiler error that says, MoveToward cannot be called here. Does anyone have ANY idea as to how I can move a bot to a vector.

Thanks,

- Sid
 

Darknigh+

New Member
Oct 19, 2003
113
0
0
www.cis.usouthal.edu
The reason the MoveToward didn't work is because it takes and actor as its destination. You want to use the function MoveTo and these functions can only be used inside states.
 

redeemer90

New Member
Oct 7, 2004
4
0
0
Thanks :)

Thanks for this tip. I will give it a try when I get back to my comp with ut2k4. I will try calling the function from my custom bot class. Hopefully it should work.

Once again,

Thanks.

- Sid

Darknigh+ said:
The reason the MoveToward didn't work is because it takes and actor as its destination. You want to use the function MoveTo and these functions can only be used inside states.
 

redeemer90

New Member
Oct 7, 2004
4
0
0
Still does not work :-(

Sorry, but it still doe not seem to work. As you can see from the code below, I am writing to the log file from several places. All these functions get called during some part to the game, but the bot never seems to go to a certain location. Any idea why it does not work?

Code:
class NewController extends xBot;


function ResetSkill()
{
}

state MoveToGoal
{

	function bool CheckPathToGoalAround(Pawn P)
	{
		Log ("MoveToGoal >>> CheckPathToGoalAround");
		if ( (MoveTarget == None) || (Bot(P.Controller) == None) || !SameTeamAs(P.Controller) )
			return false;

		if ( Bot(P.Controller).Squad.ClearPathFor(self) )
			return true;
		return false;
	}

	function Timer()
	{
		//Log ("MoveToGoal >>> Timer");
		//SetCombatTimer();
		//enable('NotifyBump');
	}

	function BeginState()
	{
		Pawn.bWantsToCrouch = Squad.CautiousAdvance(self);
		Log ("MoveToGoal >>> BeginState");
	}
	
begin:
	if (self != None)			
	MoveTo(Destination);
	Log ("MoveToGoal >>> begin:"$Destination);
}

//copied from bot class

function SetAttractionState()
{
	Log ("Set attraction");
	if ( Enemy != None )
		GotoState('FallBack');
	else
		GotoState('MoveToGoal');
}

Thanks for your help so far.

- Sid

Darknigh+ said:
The reason the MoveToward didn't work is because it takes and actor as its destination. You want to use the function MoveTo and these functions can only be used inside states.
 

Darknigh+

New Member
Oct 19, 2003
113
0
0
www.cis.usouthal.edu
MoveTo can't be in the begin of a state. Forgot to mention that earlier, my bad....;) So change this:

Code:
begin:
	if (self != None)			
	MoveTo(Destination);
	Log ("MoveToGoal >>> begin:"$Destination);

To something like this:
Code:
MoveToVectorLoc:
        if (self != None)			
	MoveTo(Destination);
	Log ("MoveToGoal >>> begin:"$Destination);
 
Last edited: