Announcement

Collapse
No announcement yet.

Problem in AI

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

    Problem in AI

    Hi guys, I'm working to a top down shooter and I'm stuck with the AI.
    I found this quick-start guide on the Unreal Documentation: https://docs.unrealengine.com/latest...art/index.html
    which is perfect for my project, so I builded up all the blueprints and applied the Controller (Follower AI CON) to my enemy character as the default controller.

    I also builded up a simple spawn for enemies, which is the following:
    Click image for larger version

Name:	Cattura.PNG
Views:	1
Size:	429.5 KB
ID:	1179608
    I used an Event dispatcher: There is a trigger box (called Spawn Enemies) that calls this on the level blueprint.
    It's very simple: after the Overlap event, "Spawn AI from class" spawns an enemy, and the number of enemy spawned is increased by one. Until this number is less than the spawn limit value, it keeps spawning. The spawn location of each pawn is choosed randomly from a group of target points placed on the map.

    I don't think this could be the reason of the problem, but since I've made it on my own and I'm not very experienced, maybe there is something to change, in order to make the IA working correctly.

    I'll briefly explain how the IA should work: When the enemy is spawned, his location is stored in the HomeLocation variable. If he see the HeroCharacter, he moves to his location. If he loose his target, he stops and waits for 2.5 sec and then returns to his HomeLocation.
    What actually happens when I hit play is: If an enemy sees me, he runs to my location. If I make him loose the target, he just stays still and does not go back to HomeLocation. If I make him see me again, he correctly follows me.
    When I stop the game, I receive this error log:
    Click image for larger version

Name:	Catturaz.PNG
Views:	1
Size:	9.9 KB
ID:	1179609

    And the reason is the Get Controlled Pawn node, as you can see here:
    Click image for larger version

Name:	12901123_1099453126763501_1146196331779698906_o.jpg
Views:	1
Size:	440.4 KB
ID:	1179610

    I think that when the pawn is spawned, the controller does not immediately take possess of him, so the HomeLocation variable cannot be stored, (this could explain why enemies don't go back to HomeLocation) but the fact that the enemy runs to me means that at a certain point the controller "appears".
    So... has someone and idea of why this appens? How can I fix it? I'm really desperate, I tried everything.
    Hoping I explained clearly the problem, thank you

    #2
    Yes, don't set the BlackBoard value on BeginPlay, set it after the BehaviorTree has started.

    Comment


      #3
      Uhm.. do you mean something like this?
      Click image for larger version

Name:	CatturaFR.PNG
Views:	1
Size:	799.3 KB
ID:	1103827

      because does not work yet..

      Comment


        #4
        Add a delay at the beginning of your begin play.

        Or better, add something that asks if the pawn is valid, if its not it waits 0.1 seconds and tries again until it is.
        [Released] Multiplayer Combat Editor
        A-RPG Sacred Swords
        Auto-Chess Live Development
        Youtube Tutorials

        Comment


          #5
          It works!
          ..partially..

          Now the Controlled Pawn is valid (I can't believe it was so simple, I feel a little bit stupid), but HomeLocation results invalid on the behavior tree yet.
          This time I can't really figure out what could be wrong.. "When controlled pawn is valid, get its location and store it in HomeLocation", seems ok to me..
          I also tried to swap the "Run Behaviour tree" and "set value as vector" positions (set value and then run the bt) but nothing changes.

          Click image for larger version

Name:	Cattura.PNG
Views:	1
Size:	277.3 KB
ID:	1103841
          Click image for larger version

Name:	Cattura2.jpg
Views:	1
Size:	870.6 KB
ID:	1103845
          Attached Files
          Last edited by Jezeph; 04-04-2016, 03:58 PM.

          Comment


            #6
            Try storing your pawn in a variable and feed that into the actor location pin.
            [Released] Multiplayer Combat Editor
            A-RPG Sacred Swords
            Auto-Chess Live Development
            Youtube Tutorials

            Comment


              #7
              You are right to run the BT first, but Try this:

              Instead of wiring the pin straight into setting the BlackBoard value, use a Timer, make an initialize event and call it .1 or .2 after the BT has run.

              Comment


                #8
                Hope I did not misanderstood your instructions guys, but it's still the same with both the solutions: HomeLocation invalid.
                These are the blueprints I tried (First one is the Yun-Kun advice, the second one is mikepurvis one):

                Click image for larger version

Name:	Cattura6t.PNG
Views:	1
Size:	252.8 KB
ID:	1103852

                Click image for larger version

Name:	Catturafd.PNG
Views:	1
Size:	309.8 KB
ID:	1103853

                Comment


                  #9
                  couldn't it just be some event that are sent by the behavior tree setup?(I'm out of AI loop a bit, so please forgive me if this is intended behavior)
                  It seems really odd that you have to rely on a delay function to retry, instead of just use event chains to setup everything properly.

                  EDIT: after recheck OP, it seems that you can derive a AI Controller to make your life easier if a valid controller is essential for your event flow. So there should be a Event On Possess for you to use after a AIController is spawned and hand over possession of your AI Pawn.
                  Last edited by PenguinTD; 04-04-2016, 07:24 PM.
                  Unreal Engine 4 Game Framework diagram for relation of all major base object types
                  Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                  Resident Evil Classic Camera
                  RPCs official document, Must Read
                  Everything you should know about replication

                  Comment


                    #10
                    Keep your setup.

                    Remove your "use blackboard" node.

                    Just run your BT like you do, adding the key afterwards.

                    If it doesnt work, try the PenguinTD's logic.

                    I never used the "set blackboard" node, I have a feeling that it is supposed to be used if you want to switch from the original blackboard you set up in your behavior tree. But I'm not sure.
                    [Released] Multiplayer Combat Editor
                    A-RPG Sacred Swords
                    Auto-Chess Live Development
                    Youtube Tutorials

                    Comment


                      #11
                      I tried to remove the UseBlackboard node as Yun-Kun said and the beahaviour tree works as normal, so it was clearly useless.
                      ..but HomeLocation is still invalid.

                      I didn't get the PenguinTD's logic, what do you mean? How should I use the Event On Possess?

                      Comment


                        #12
                        You should follow that video.



                        He's basically doing what you want to do I believe.
                        [Released] Multiplayer Combat Editor
                        A-RPG Sacred Swords
                        Auto-Chess Live Development
                        Youtube Tutorials

                        Comment


                          #13
                          I watched the video and noticed that he links anything to the get blackboard node. So I did and.. it works now! I just basically removed the self reference, I don't even know why it was there..
                          I mean, the blueprint is a controller class, so what is the point to use a self reference of a blackboard..?

                          Anyway, the final blueprint is the following:

                          Click image for larger version

Name:	Cattura.PNG
Views:	1
Size:	210.0 KB
ID:	1103966

                          I really have to thank you for the help guys, you have been so kind!
                          Last edited by Jezeph; 04-06-2016, 03:39 PM.

                          Comment


                            #14
                            I followed the same 'tutorial', but it ends up being a mash of unorganized references. I also do not think it uses the AI tree correctly (try issuing a new command while in the middle of one, didn't work for me) Also had issues with the AI moving to world origin on spawn and under certain conditions (when MovetoActorOrLocation has null for an actor reference).
                            This is my setup: http://imgur.com/a/LU58t (open images in new tab, they are large)

                            AI Tree + AI Controller: http://i.imgur.com/WEIcbbv.png
                            AI Tree Service: http://i.imgur.com/tJtzZGi.png
                            Attached Files
                            Last edited by Nodrak; 04-11-2016, 05:22 PM.

                            Comment


                              #15
                              I've noticed that, we had a lot of troubles on making it working correctly, and I can't even say in does now. Everything's fine until we have one or two enemies on the map, but when they are a few more and they touch each other to reach the same location (for example, TargetToFollow) it seems like they loose their HomeLocation value, infact if you make them loose their target, some of them go back to HomeLocation as expected, some others just stay where they are until they're alive.

                              What about your setup? I'm quite noob yet, it makes IA move to mouse location, like a strategic game?

                              Comment

                              Working...
                              X