Announcement

Collapse
No announcement yet.

How to use path finding for a non actor.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.
    Some cool unreal projects you may like!


    Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

    Download the demo Download the demo
    external link Dropbox DropBox

    Become a c++ Professional now C++ Networking Tutorial

    #2
    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?

    Comment


      #3
      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?
      Some cool unreal projects you may like!


      Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

      Download the demo Download the demo
      external link Dropbox DropBox

      Become a c++ Professional now C++ Networking Tutorial

      Comment


        #4
        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.
        Last edited by gamepainters; 09-09-2020, 04:37 PM.

        Comment


          #5
          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.
          Some cool unreal projects you may like!


          Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

          Download the demo Download the demo
          external link Dropbox DropBox

          Become a c++ Professional now C++ Networking Tutorial

          Comment


            #6
            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.

            Comment


              #7
              ok i'll see what i did wrong...
              Some cool unreal projects you may like!


              Developer of GOTA - Survivalism Gladiatorial game Buy the game google gladiators of the arena steam https://store.steampowered.com/app/7..._Of_The_Arena/

              Download the demo Download the demo
              external link Dropbox DropBox

              Become a c++ Professional now C++ Networking Tutorial

              Comment


                #8
                glad you solved it.

                Comment

                Working...
                X