Announcement

Collapse
No announcement yet.

AI tasks to get actors In map Not working :(

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

    AI tasks to get actors In map Not working :(

    I followed A tutorial to learn how to get the nearest actor of type in a map. https://www.youtube.com/watch?v=w8G7zMhehP8
    And I tried to turn it in to an AI TASK so my simple AI bots will find all the capture points I place in My map and pick the nearest one then move to it.

    I also Made a pick random Capture point task.
    Unfortunately None of them work and my AI just stands in place.
    My nav mesh is all set up and If I use the get random location and move to its working fine , But these custom tasks dont.
    Can anyone spot why they are note working.

    Get nearest Capture point
    Click image for larger version  Name:	Capture Nearest.png Views:	0 Size:	481.0 KB ID:	1781805Get random capture point
    Click image for larger version  Name:	Capture.png Views:	0 Size:	391.8 KB ID:	1781806
    https://www.artstation.com/alphawolf
    https://www.deviantart.com/alphawolf-uk/gallery
    https://www.youtube.com/user/AlphaWoIFuk/videos

    #2
    Can you be a little more specific. What exactly is not working? The target's selection, the blackboard values, the behaviour tree, ...
    The print strings, to they print the right target?


    One little remark on your bps: with "get all actors of class X" you already got an array. Why the for loop to read and set the "capture point" array? Why not, set "capture point" directly from the "get all actors of class X" output pin:

    Click image for larger version  Name:	1.jpg Views:	0 Size:	21.7 KB ID:	1781834
    Last edited by EvilCleric; 06-28-2020, 10:18 AM.
    "I have harnessed the shadows that stride from world to world to sow death and madness."

    Comment


      #3
      Also, in the get the closest task:

      Click image for larger version  Name:	1.jpg Views:	0 Size:	86.3 KB ID:	1781844

      Shouldn't it be:

      Click image for larger version  Name:	2.jpg Views:	0 Size:	72.4 KB ID:	1781845

      Edit:

      In the BT, tasks selected, did you set the blackboard key in the details panel (MoveToLocation for the first and Location for the second):

      Click image for larger version

Name:	3.jpg
Views:	25
Size:	19.4 KB
ID:	1781854
      Last edited by EvilCleric; 06-28-2020, 10:47 AM.
      "I have harnessed the shadows that stride from world to world to sow death and madness."

      Comment


        #4
        The top bit is just a leftover from me doing trial and error trying to trouble shoot it if you look at the second pic I made the right choice like you suggested.
        But as for the extra loop that was what the tutorial I followed did. And what part thats not working is the characters not moving even thought I can see to location printed to screen. I am setting the BB key to the target location.
        https://www.artstation.com/alphawolf
        https://www.deviantart.com/alphawolf-uk/gallery
        https://www.youtube.com/user/AlphaWoIFuk/videos

        Comment


          #5
          You see it printing. How about the values in the BB? Do they get the right value?

          Click image for larger version  Name:	1.jpg Views:	0 Size:	25.2 KB ID:	1781887

          Also, when executing, what happens in the tree? I mean, it executes the point selection task and then the move task or it just keeps running the selection task or it's all over the place?
          "I have harnessed the shadows that stride from world to world to sow death and madness."

          Comment


            #6
            I remade the random selection Task and made it as minimal as possible.
            Click image for larger version  Name:	Random.png Views:	0 Size:	138.0 KB ID:	1781933
            And in the game screen the random selected Capture point is selected in blue and the world location is in yellow. But in the BT I can see the task is static and not moving to move to.
            I have to put a do once node in the task otherwise its constantly running and spamming the random selection on the screen while the BT is task is flickering due to constantly running.
            I have the finish execute node so Im not sure why its not moving to move to. If i swap the task with select random location in nav mesh it works.
            Click image for larger version  Name:	bt.png Views:	0 Size:	608.0 KB ID:	1781934
            https://www.artstation.com/alphawolf
            https://www.deviantart.com/alphawolf-uk/gallery
            https://www.youtube.com/user/AlphaWoIFuk/videos

            Comment


              #7
              Your code looks good.

              So, remove the "Do Once".

              The flickering is usually because of an invalid value, which you could watch if it's in the details panel during execution:

              Click image for larger version  Name:	0.jpg Views:	0 Size:	174.3 KB ID:	1781952
              • So, is your "MoveToLocation" variable Invalid or does it has a valid value?
              • Is your "MoveToLocation" key variable public?
              Click image for larger version  Name:	1.jpg Views:	0 Size:	29.6 KB ID:	1781951
              • Have you also select "MoveToLocation" not only in the "MoveTo" task but also in the "OBJECTIVE" task?
              Click image for larger version  Name:	2.jpg Views:	0 Size:	121.8 KB ID:	1781953
              Last edited by EvilCleric; 06-28-2020, 03:38 PM.
              "I have harnessed the shadows that stride from world to world to sow death and madness."

              Comment


                #8
                Everything Is as it should be and all it does is loop between the task and the move to task without ever moving. I am starting to believe this method will not work no matter what.
                Just for testing purposes I created this
                Click image for larger version

Name:	TEMP.png
Views:	15
Size:	107.0 KB
ID:	1781983and set the same move to location BB key. and swapped it with the Task in the BT. and it works right away . so its defiantly something to do with the code imo
                https://www.artstation.com/alphawolf
                https://www.deviantart.com/alphawolf-uk/gallery
                https://www.youtube.com/user/AlphaWoIFuk/videos

                Comment


                  #9
                  Well, if MoveToLocation has a valid value in the BB (so, it can't be from the code - the code must be working as expected, afterall, it printed the right results, right?) and both MoveTo and OBJECTIVE tasks are set to MoveToLocation, then there is no reason not to work.

                  I can't see any problem. Perhaps someone else can.
                  Last edited by EvilCleric; 06-28-2020, 05:22 PM.
                  "I have harnessed the shadows that stride from world to world to sow death and madness."

                  Comment


                    #10
                    Just had some luck . I started to add ontop of the test code above and was surprised to find that Its only working with the Vector + vector .
                    Click image for larger version  Name:	TEMP.png Views:	0 Size:	127.9 KB ID:	1781988If I remove the vector + vector it stops working, even with the actor loc plugged directly in the the BBkey selector . or even as a promoted variable.
                    Strange they don't work unless I add the vector + vector
                    Now I will Test it with the All Actors off class and not just a single
                    Last edited by AlphaWolF; 06-28-2020, 05:28 PM.
                    https://www.artstation.com/alphawolf
                    https://www.deviantart.com/alphawolf-uk/gallery
                    https://www.youtube.com/user/AlphaWoIFuk/videos

                    Comment


                      #11
                      Yep its working .
                      Been trying to solve this ALL bloody day. And the solution was so simple , even if I still don't fully understand why it works like that and not directly from the actors world location or a promoted variable of it.
                      Well at least others are going to gain from my struggles,
                      Last edited by AlphaWolF; 06-28-2020, 05:36 PM.
                      https://www.artstation.com/alphawolf
                      https://www.deviantart.com/alphawolf-uk/gallery
                      https://www.youtube.com/user/AlphaWoIFuk/videos

                      Comment

                      Working...
                      X