Announcement

Collapse
No announcement yet.

How to refocus or retarget enemy with towers?

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

    How to refocus or retarget enemy with towers?

    I am making a tower defense game and what I have so far is okay, but I am wondering how to get my towers to "keep up" with my enemy. I've adjusted the Interp Speed and they are still semi-focused. Any help on tightening up the targets would be greatly appreciated. Thanks...

    Last edited by NuHabit; 06-12-2018, 12:31 AM.

    #2
    You need to check if an enemy is in range. If it is, aim at the enemy. If not, increase rotation by +1 (for turning around). You get the idea. You can have 2 different states, one fighting state, one idle state.

    Comment


      #3
      Here is a new link to a video to show what I am talking about. The last link is bad apparently...

      https://youtu.be/bUzlKyDw1I8

      Comment


        #4
        So as anyone can see, it starts just fine, but after they all are inside the collision, it stops shooting them. I am seeing on collision enter, but not while in collision. How do I update while / if they are inside the collision still?

        Comment


          #5
          Still looking for help on this. Just need to keep or figure out how to update current overlaping enemies as targets and follow them all the way and not partially.

          Comment


            #6
            Get overlapping actors, sort by health remaining, set the winner as the target for the turret. Fire at it for as long as it's overlapping or update every frame if you want to switch to the weakest target available.

            Comment


              #7
              Thanks, I will give that a try.

              Comment


                #8
                I have an older experimental project somewhere with tower defense elements. Let me know if you're having problems with this and I'll try to dig it up and see if it makes sense in 4.19

                Comment


                  #9
                  If you know how to sort by remaining health or update every frame, it would save me some research time. And be appreciated.. lol I am using 4.18 though.
                  Last edited by NuHabit; 06-12-2018, 05:54 PM.

                  Comment


                    #10
                    Turrets have a collision sphere which checks for overlapping actors, puts their health into an array and fetches the one with the lowest value. The retrieved object is then set as target for the turret for as long as it's alive, is in range or something with lower health comes along...

                    Click image for larger version

Name:	Capture.PNG
Views:	5
Size:	150.5 KB
ID:	1488378

                    Apart from that there are some more elements when it comes to target selection. The project is attached if you want to take it apart, it's just 3 blueprints, really. Some stuff in the construction scripts, some widgets and it all spawns in the level blueprint.

                    Link to the project (20MB): https://drive.google.com/open?id=1dm...J_il6Lx_d8YXPz

                    Vid: https://i.gyazo.com/beee742e871e5d43...688a22e54d.mp4

                    Hope it helps.

                    Comment


                      #11
                      Thanks that helped a lot. Much appreciated.

                      Comment

                      Working...
                      X