Announcement

Collapse
No announcement yet.

Assigning unique paths for pawns

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

    Assigning unique paths for pawns

    Hi,

    I'm trying to get my AI controlled guards to patrol around a map using their own unique path using ScriptedSequences. However the ScriptedSequence action: MoveToPoint will consider all the PathNodes placed in the level which sometimes take "short cuts" to other near by PathNodes to get to it's next point goal. Obviously its bad to have guards patroling on a very fixed set of path nodes to veer off to neighboring nodes.

    I can used the ProscribedPoints to limit which nearby path nodes are off limits but this is a lot of bookkeeping and I can only have 4 ProscribedPoints (off limit nodes) per PathNode. I could this being problematic.

    Is there a way to assign a unique path to a unique pawn so only that pawn will uses it "owned" PathNodes?

    Thanks for any suggestions.

    #2
    I THINK there are patrol points, where you can define a patrol by numbering the patrol points in a bots patrol.

    Is that not correct?

    Check this out and see if it helps:
    Patrol Points Tutorial

    Comment


      #3
      No patrol points that I could find in UT2004. And creating a lot of nearby PathNodes creates a connecting web of chaos. I'm about to give up on doing it with scripted sequences and writing the code from scratch.

      Comment


        #4
        Are you creating the map from scratch?

        Is PatrolPoint not a subclass of NavigationPoint?

        Comment


          #5
          When I get home I can check the code for how I did it in UT2003.

          There may be a way to set the "patrol regions" in their own zones in a map, and then add the nav points in a particular zone up in an array. Then you could have the bot go through the points in the array...

          Comment


            #6
            Originally posted by cknight52
            Are you creating the map from scratch?

            Is PatrolPoint not a subclass of NavigationPoint?
            Ya, I thought about that but any NavigationPoint dervied class is automatically considered as a viable node for traversal and is automatically added to the path node graph in UnrealEd.

            Not sure how to set up 'regions' of paths. I looked but couldn't find anything related to that topic.

            I'm current implenenting my own pathing system. I'm current deriving my own node class off of actor and contructing the path via information stored in each node.

            Then when my Pawn is created I check the world for these points and start it off on its merry way.

            Thanks for the help.

            Comment


              #7
              So you want these nodes to be traversed only by these particular pawns?

              Comment


                #8
                Originally posted by cknight52
                So you want these nodes to be traversed only by these particular pawns?
                Well I need the pawn to follow a defined path (Point A -> Point B -> Point C, etc) and either reverse back or loop.

                The problem really starts to get complicated when you have 2 or 3 pawns walking along nearby paths. Like 3 guards walking abreast down a street area. Where each path is very near the others. The way UnrealEd creates path links between the Path Nodes in this case causes a load of problems.

                Comment


                  #9
                  Oh by the way, when I said regions I didnt mean to imply they already exist. I was just using a generic term.

                  What I meant was that you can iterate through actors in a zone. You can zone off areas in a map, and then iterate through actors only in that zone.

                  So what I was saying is that you could create an array of path nodes in a particular zone. Then the pawn could use that node array to walk through.

                  Comment


                    #10
                    Would it be easy to make by
                    decompiling the PatrolPath
                    thing from U1/UT99 and modify
                    it a bit and import to UEd 3.0?

                    Or no?

                    Comment


                      #11
                      Originally posted by Format Life:
                      Would it be easy to make by
                      decompiling the PatrolPath
                      thing from U1/UT99 and modify
                      it a bit and import to UEd 3.0?

                      Or no?
                      That's an idea but I'm just writing my own pathing system for what I need. I creating a new PatrolNode class that is derived form Actor. Each patrolling pawn will have a string associated to a list of PatrolNodes and the pawn will search the map for PatrolNode with the corresponding name at load time.

                      I'll use PathNodes to mark out the basic paths and hope that if they are close the pawns will go linearly from my PatrolNode to PatrolNode. I'm not sure this is going to happen however...

                      Comment


                        #12
                        Nice! That's going to be in a mod or?

                        Comment


                          #13
                          Ok. I wanted to have the code in front of me, but I cant access my F'in FTP server from work.

                          So basically the way that I did something like this was:

                          1) Get an array of nodes within a radius of the bot. Like
                          Code:
                          // global var
                          var NavigationPoint[] nodeArray;
                          
                          function getNodes()
                          {
                            local NavigationPoint tempPoint;
                            local int arraySize = 0;
                            local int x = 0;
                            foreach Radius.Actors(class'NavigationPoint',tempPoint,2098)
                            {
                              arraySize++;
                            }
                            nodeArray.size = arraySize;
                            foreach Radius.Actors(class'NavigationPoint',tempPoint,2098)
                            {
                              nodeArray[x]=tempPoint;
                              x++;
                            }
                          } // end function
                          You would call that function like in postBeginPlay for your bot class. Then you would have like a roaming state:
                          Code:
                          state Roaming
                          {
                            local int currentPosition = 0;
                            Begin:
                              if(currentPosition > nodeArray.Size)
                                currentPosition = 0;
                              currentPosition++;
                              MoveToward(nodeArray[currentPosition];
                              GotoState('Roaming','Begin');
                          }
                          Theres more to it, but thats basically it. YOu want to check if the bot is touching the navigation before you send him after the next one. Shoot if I had the code... lol.

                          Comment


                            #14
                            I'd like to see your method cknight52 if you get ahold of your code.

                            This is for a mod but not for the public per se. I'm doing a mod as a demo for game prototype. So it a total conversion type mod. Lots of changes to the basic Unreal functionality sadly. I'm not able to use the Bot code which is a sucks since it works so well and Epic has put so much time into it making it work well.

                            I got my new pathnode code and data working in my mod. Surprising it didn't take much code to get it working. The method I described above worked except I had to build the list of points in the my controller's Possess() instead of it's PostBeginPlay since I don't have a reference to Pawn in PostBeginPlay(). (The pawn tells the controller which patch it wants to use, set in the map).

                            Comment


                              #15
                              Heres the important stuff from the bot subclass

                              Code:
                              class Cyclops extends chrisBot;
                              
                              var PathNode destinationNode;
                              var NavigationPoint RoamDestination; 
                              var array<NavigationPoint> cyclopsArray;
                              var int numOfNodes;
                              
                              function PostBeginPlay()
                              {
                                 Super.PostBeginPlay();
                                  InitializeEnemy();
                                  GotoState('Roaming','Begin');
                              }
                              
                              function Restart()
                              {
                                  Super.Restart();
                                  getCyclopsNodes();
                                  GotoState('Roaming','Begin');
                              }
                              
                              //  Take control of a pawn, then go to the roaming state.
                              //  this gets the cyclops to be possessed by the cyclopsPawn
                              //  It then sends the cyclops into cyclopsMainState
                              function TakeControlOf(Pawn aPawn)
                              {
                                  if ( Pawn != aPawn )
                                  {
                                      aPawn.PossessedBy(self);
                                      Pawn = aPawn;
                                  }
                                  GotoState('Roaming','Begin');
                              }  // end TakeControlOf
                              
                              // a function that will return whether the bot it close to the node
                              function bool isClose(Actor closeActor)
                              {
                                local float holdingDistance;
                                local float xDistance;
                                local float yDistance;
                              
                                xDistance = abs(Pawn.Location.X - closeActor.Location.X);
                                yDistance = abs(Pawn.Location.Y - closeActor.Location.Y);
                                holdingDistance = xDistance+yDistance;
                                if(holdingDistance <= 30)
                                  return true;
                                else
                                  return false;
                              }  // end isClose
                              
                              function getCyclopsNodes()
                              {
                                 local NavigationPoint arrayNode;
                                 local int arrayIndex;
                              
                                 arrayIndex = 0;
                                 numOfNodes = 0;
                              
                                 foreach RadiusActors(class'NavigationPoint', arrayNode, 2048)
                                 {
                                    cyclopsArray[numOfNodes] = arrayNode;
                                    numOfNodes++;
                                 }  // end for
                              }  // end getNodes
                              
                              //  this is the default state for the cyclops
                              //  the cyclops will roam around the field
                              state Roaming
                              {
                                  function Tick( float DeltaTime ) {
                                     if ( isClose(cyclopsArray[myArrayIndex]) ) {
                                        myArrayIndex++;
                                        if ( myArrayIndex == numOfNodes )
                                           myArrayIndex = 0;
                                        GoToState('Roaming','Begin');
                                     }
                              
                                  }
                              
                              Begin:
                                 MoveToward(cyclopsArray[myArrayIndex]);
                              
                              }

                              Ive taken stuff that didnt relate directly to this out. The above code will just make the bot roam around in the nodes in that radius.

                              You will want other code, to include like if something happens near it and shtuff.

                              Comment

                              Working...
                              X