Download

How to use path finding for a non actor.

I want to use path finding for a 3d point, BUT it won’t can you guys share the code for it ? I just can do it with moveToward and actors… hehe
Will post the code later on if needed.

Are you using navigation points?
What are you wanting to do?
spawn your player there? or just move a bot to that point?
What are you trying to accomplish?

I can do path finding for actors like go to actor A, But i can’t for 3d points on the level. Posting code soon… Any tutorial out there?

You can try this not sure if it will work or not.
in the file SeqAct_AIMoveToActor try adding in a new var like so.

var() Vector Location_Destination;

line 42 make it a 3 not a 2.
return Super.GetObjClassVersion() + 3;

then in default properties add this.
VariableLinks(3)=(ExpectedType=class’SeqVar_Vector’,LinkDesc=“Location_Destination”,PropertyName=Location_Destination)

So when you want to go to that point go to its location which should be a vector. Not for sure if it will work until you test it to see if it works.
You should be able to hook up a SeqVar_Vector to that new Location_Destination. then put in your x y z in the SeqVar_Vector.

So this is my code to find path towards actor

function bool FindNavMeshPathForActor( actor PathActor)
{
//Clear the cache and the constraints
Navigationhandle.PathConstraintList = none;
Navigationhandle.PathGoalList = none;

//Create the constraints
Class’NavMeshPath_Toward’.static.TowardGoal(NavigationHandle, PathActor);
Class’NavMeshGoal_At’.static.AtActor(NavigationHandle, PathActor, 32);

return NavigationHandle.FindPath();
}

state using it.

state GetCloseToTheEnemy
{

function BeginState(name PreviousStateName)
{
SetDesiredDestination(Oponent.Location);

StopLatentExecution(); //Prevents from getting stuck with the moveto

AvoidRunawayValue = 0;
StandartState = ‘GetCloseToTheEnemy’;

}

function Timer_MovementTick()
{

}
function Timer_DefensiveTick()
{

}
function Timer_AgresiveTick()
{

if(GOTAMP2Pawn(Pawn).InventoryReference.PrimaryWeapon != none)
{

if( !IsTimerActive( NameOf(CooldownAgresiveAction) ) && !IsTimerActive( NameOf(CooldownDefensiveAction) ) && vSize( Oponent.location - pawn.location ) < 300 && vSize( pawn.velocity ) > 100)
{

PerformJumpAttack();
SetTimer(RandRange(0.5, 1) , false, NameOf( CooldownAgresiveAction ) );

if( !IsTimerActive(NameOf(JumpAttackCooldwoner ) ) )
{
SetTimer( JumpAttackAgainTime , false, NameOf( JumpAttackCooldwoner ) );
}

}
}

}
function Timer_AttentionTick()
{

if(Oponent != none)
{
if( VSize(Pawn.location - Oponent.location ) < 200)
{
GoToState(‘AttackTheEnemy’);
}
}

//Case survival game info
if(GOTAMP2SurvivalGameInfo(Worldinfo.game) != none)
{

if( GetActorToCloseToThenDodge() != none )
{
FoliageOrConstructionToDodge = GetActorToCloseToThenDodge();

GoToState(‘AvoidingFoliageOrConstructionActor’);

}
}

if( !IsTimerActive( nameOF( AttackPlayerInHordeTimerBased ) ) )
{
Oponent = GetNearestAliveOpponnentHavingPlayerPriority();
}

if(Pawn == none)
{
//`log(“FROM GOTAMP2AIController the pawn is none”);
}
}

begin:

if( Oponent != none )
{

//Navigation path NAVMESH, no waypoints in use somehow
if( NavigationHandle.ActorReachable(oponent) )
{

MoveToward( oponent, none, 50 );
//DrawDebugSphere(DesiredDestination, 16, 20 ,0, 0, 255, true);
//FlushPersistentDebugLines();
}
else if( FindNavMeshPathForActor(oponent) && AvoidRunawayValue < 200 )
{
AvoidRunawayValue++;
//`log("FROM AIController the runaway is "@AvoidRunawayValue); removes the bug
NavigationHandle.SetFinalDestination(oponent.location);
//FlushPersistentDebugLines();
//NavigationHandle.DrawPathCache(,true);

if(NavigationHandle.GetNextMoveLocation(DesiredDestination, Pawn.GetCollisionRadius() ) )
{
//DrawDebugLine(Pawn.location, DesiredDestination, 255, 0, 0, true);
//DrawDebugSphere(DesiredDestination, 16, 20 ,255, 0, 0, true);
//MoveToward( oponent, none, 100 ); //This was wrong
MoveTo(DesiredDestination );
}

}
else
{
MoveToward( oponent, none, 100 );
}

}
else
{
MoveTo(pawn.location);
}
if ( Pawn == none )
{
//GoToState(‘DeadAI’);
}

goto’Begin’;

So I want the same thing but using a 3d point… A vector.

the location is a vector. The other functions use actor as a parameter. you cant change that to a vector. with out source code to rewrite native code so you could make new function to accept a vector parameter.

i see that MoveTo(pawn.location); and this NavigationHandle.SetFinalDestination(oponent.location); function take a vector parameter. which would be a 3d point.

ok i’ll see what i did wrong…

glad you solved it.