UE4 Turret Tutorial Part 2 - Multiple Targets

Поделиться
HTML-код
  • Опубликовано: 28 дек 2024

Комментарии • 61

  • @powerpc6037
    @powerpc6037 3 года назад +4

    I followed your tutorial and it's excellent. Easily understandable and very clear and above all, it works. One issue for my game: enemies could hide behind walls or obstacles and it would be pointless to keep the turret focused on that target and keep shooting while there could be other targets in range that aren't behind an obstacle and could move freely past the turret without getting shot at. My turrets will also consume ammo and can eventually run out of ammo, so shoothing at a target in range that cannot be hit (the obstacle would be hit instead of the target) is pointless. There will also be npc's that spawn in a building when a turret is almost out of ammo and they should run towards the turret to restock it's ammo. If that npc is killed, a new one needs to take it's place or be revived by another healer npc and this delay can make the turret to run out of ammo completely and your city will be vulnerable as the turret won't be able to kill incoming enemies without ammo. So I reverted back to aiming using the Tick event. The overlap just adds/removes the actor to/from the array and with a delay of 0.2s, I search for hittable targets in it's array. If the current target is valid, do a linetraceforobject and if it can be hit, keep that target. If it can't be hit anymore, clear the target and search for another target in the array that CAN be hit and set that as the target, but also monitor the distance between every target and turret to choose the closest hittable target. There would be no point in trying to hit a target 25m away who just entered the turret's range when there is an enemy right next to the turret that can be hit. Unless the nearest target just came out of hiding while the target who just entered the turret's range was already selected as the target, then the turret will keep that far-away target and won't switch to that nearby target until the far-away target either leaves the range or is dead. It will not switch hittable targets while a hittable target is still selected. I'm still learning the engine but I figured this out on my own but used your example to get started. Otherwise I wouldn't have figured out the math involved as my math isn't that good anymore either :p

    • @CrazyCatDev
      @CrazyCatDev  3 года назад

      Thank you for your kind words about my tutorial! Regarding 'cover' for enemies as you described, the next tutorial in this series is going to be all about adding cover and using line traces to detect whether the turret can fire. I'm glad you found your own solution and I must say it is similar to what I would do, so well done. :)

    • @powerpc6037
      @powerpc6037 3 года назад

      @@CrazyCatDev I'm using the Tick event to check if there is a valid target set. If there is a valid target, check if it can be hit. If so, aim at it. If it can't be hit, check the TargetList array to find another target in range that can be hit. If the current target isn't valid, also try to find a new target. If there is no target set after this, reset aim using the Tick event. Later on, I want my turret to swing left to right when it's resetting it's aim like it's searching for a target. So I'll keep using the Tick event instead of using the sequence+gate and build a loop around it manually.

    • @CrazyCatDev
      @CrazyCatDev  3 года назад +1

      @@powerpc6037 That will certainly work. My only concern with Tick is it can become resource heavy rather quickly, especially with lots of turrets running at once.

    • @powerpc6037
      @powerpc6037 3 года назад

      @@CrazyCatDev That won't be a problem. There will be a max of 6 turrets in front of the walls, maybe 3 cannons on top of the walls, maybe a trebuchet behind the wall or something similar (not sure about this yet, game is still in design fase and it's slow going since my drawing skills are below average) and such. I won't put hundreds of turrets near the walls of my town. I plan only to have 2 turrets per gate and there will only be 3 gates. Of course, the player will also be able to put down some turrets in the field while hunting or farming for materials, but there also will be a max amount the player is allowed to put down at once. A bit like RF Online but it will be singleplayer. It's hard as it is making a single player game, don't want to extra trouble making it multiplayer for my very first game.

  • @Johanvp
    @Johanvp 4 месяца назад +1

    Got this working as well. Great one.

  • @MurTag93
    @MurTag93 4 года назад +2

    Best of luck with your Channel Champ.

  • @griffithpictures
    @griffithpictures 4 года назад +1

    This is great! I'd love to see the projectile tutorial next.

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      I've been planning on doing the next video for ages, but my health has been getting in the way unfortunately. 😔

    • @griffithpictures
      @griffithpictures 4 года назад +2

      @@CrazyCatDev so sorry. Glad you're keeping social online at least.

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      @@griffithpictures I'm doing my best haha. I recently upgraded to new monitors and a new microphone so hopefully that'll motivate me to get back on the tutorials. 🤟

  • @ChaoticRay
    @ChaoticRay 3 года назад +1

    Thanks to you so much for this tutorial. And especially for explaining all the steps. It is very important. I don't want to just copy what I saw in the video. I want to understand. You explain perfectly. Even though I don't know English very well. Anyway, thanks) And you have a very cute friend^^

    • @CrazyCatDev
      @CrazyCatDev  3 года назад +1

      Thank you for your kind words! I do my best to explain my thoughts and process as I go, and I'm indescribably happy that you appreciated my efforts. 😁 I am slowly getting better at making tutorial videos, so I hope you look forward to learning more as I go. 😋

  • @lucakawe7915
    @lucakawe7915 3 года назад +2

    Really cool. Thanks a lot.

  • @FINALFORMSTUDIOS
    @FINALFORMSTUDIOS 4 года назад +1

    Just had a look at your farming Sim and would be great if you could make a tutorial on how to drag when left clicking to expand in the X and Y direction. I want to make a floor building system similar to the sims. I think your project is a great base and hope to expand on it. :)

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      I'm not sure how that would be implemented but I could certainly give it a shot and if I succeed I'll make a tutorial. 😊

    • @FINALFORMSTUDIOS
      @FINALFORMSTUDIOS 4 года назад +1

      @@CrazyCatDev ruclips.net/video/Uk8FaD775fk/видео.html This is the link I found and was super inspired by it. I was able to make a grid system where I can place objects but expanding in the X and Y direction has me stumppppped ahhah!

    • @FINALFORMSTUDIOS
      @FINALFORMSTUDIOS 4 года назад

      ruclips.net/video/ei1OlRI6Hp4/видео.html

    • @FINALFORMSTUDIOS
      @FINALFORMSTUDIOS 4 года назад

      I think that if there were something like this available to developers it would save a LOT of time for level building. I am currently making storyboards for short films using UE4 and not much of a programmer. I find myself on the art side more often. Blueprints are a bit hecktic for me but am really interested in learning more and more. :) Keep the tutorials coming and really enjoy your content. Really helps out thank you !!

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      @@FINALFORMSTUDIOS I'll give it a shot 😁

  • @ricard_chramer
    @ricard_chramer 4 года назад +1

    Awesome stuff, works great! Just one thing, what about if there is already a target in the turret collision area? What would the event be for that?

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      I think you'll have to be a little more detailed with your question, sorry.
      Are you wanting the turret to forget their current target and aim at new targets that enter the collision area?

    • @ricard_chramer
      @ricard_chramer 4 года назад

      @@CrazyCatDev Lets say that a target is already in the collision area on begin play... Then nothing happens, because no event i triggered. The events handled in the video only handles when a target goes from outside the collision area into it :)

    • @ricard_chramer
      @ricard_chramer 4 года назад

      Also, will you release a video on getting it to shoot projectiles? :) If not soon, any idea where in the blueprint I should spawn the projectile? Already added a billboard at the and of the "gun" and have a projectile blueprint...

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      @@ricard_chramer Ah, I see what you mean! I've added some nodes to the 'Turret' Blueprint and will link to a screenshot of it. If you've followed my tutorial closely enough you should be able to copy these nodes directly in to your blueprint. :)
      Link: imgur.com/r3JPY5T
      Let me know if that works for you. :)
      Regarding Projectiles: I will get on to that as soon as I can. My microphone has been mostly broken for a while now, and I've been waiting for my birthday present from my girlfriend as it is a new headset and professional microphone (she is so amazing haha). I've managed to get my current mic working again, but it is still glitchy sometimes. I'll do my best to get a tutorial on projectiles up in the next week. Feel free to find my Twitter (CrazyCatDev2342) and send me a message on there to bug me in to making the video haha!

    • @ricard_chramer
      @ricard_chramer 4 года назад +1

      Thanks a lot for the superquick response!! Your solution worked great - with some trial and error due to my own fault =) =)
      Altough I had to add a delay after beginplay, otherwise it wouldn't register an overlap. Not sure if its due to how I added my target... Anyways, works great!
      Looking forward to projectiles, happy birthday in advance and keep up the good work, these turret tutorials helped me a lot and you explained everything in a great phase but still going through and explaining the logic like a great developer should =)

  • @bezzbojnik1773
    @bezzbojnik1773 4 года назад

    Great tutorial!
    I would like to see how you can make the turret model not go to another model (for example, if the target is under the floor)

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      In this video I detailed how to prevent the turret from rotating too far (going through the floor when looking down, etc). There is a small segment in there about using the Clamp node.
      If you are referring to something else, please elaborate and I'll do my best to help you. 🤟

    • @bezzbojnik1773
      @bezzbojnik1773 4 года назад

      @@CrazyCatDev I meant this 1:24, this functionality was not in the tutorial, as a result, the turret still falls under the objects :(
      Even so, thank you for providing the algorithm, your tutorial is the most clear and simple of all that I have seen!
      I signed up and now I'm waiting for the next tutorials :)

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      @@bezzbojnik1773 I believe you'll find the information you require starting at 32:30 in the video.

    • @bezzbojnik1773
      @bezzbojnik1773 4 года назад +1

      @@CrazyCatDev I'm sorry, I have no idea how I missed this moment, thank you

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      @@bezzbojnik1773 Not a problem at all! Happy to help. 😁

  • @tryphonmanu
    @tryphonmanu 3 года назад +1

    really awesome...

  • @Dackky
    @Dackky 4 года назад

    I cannot add the Cast to Enemys to my ADD component at 10:05

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      What error are you receiving?

    • @Dackky
      @Dackky 4 года назад

      ​@@CrazyCatDev Enemys Object Reference is not compatible with Turret Stage 1 Object Reference (By Ref) and it wont conenct

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      @@Dackky You have your variables mixed up, then. The error tells you that you're trying to add a variable of the type "Enemys" in to an array of "Turret Stage 1" variables. The array needs to be of the same type of variable as what you are trying to add to it.

    • @Dackky
      @Dackky 4 года назад

      @@CrazyCatDev What do you mean? Do both of them have to be Actors or something?

  • @joellitkie8283
    @joellitkie8283 2 года назад +1

    Ive gone through several an actually built thir from scratch twice and it still is not working. I was sure to follow the steps carefully as well and even downloaded you project and put that in too for a side by side. Im not sure what the issue is. Everything works from the setup in the first video, its the setup in the second video that breaks everything. Its not detecting the overlap. Ive sent a friend request for you on Discord so I can share the project if you are able to help sort out the issues im having here. Thanks.

  • @FINALFORMSTUDIOS
    @FINALFORMSTUDIOS 4 года назад +1

    Liked and subscribed :)

  • @drakebennett9169
    @drakebennett9169 2 года назад

    Its not triggering the overlap for me?

    • @CrazyCatDev
      @CrazyCatDev  2 года назад

      That isn't much to work with to try and help you unfortunately. I assume you mean when a target enters the turret's radius, it doesn't trigger the overlap event. Have you made sure all of your collision settings are set up correctly? Does the mesh that you are using for your target have a collision bounds created for it? In the static mesh editor window that appears when double-clicking in the browser window, does it have a collision bounds created there?
      If you still can't figure it out, you can add me as a friend on Discord and I'd be happy to assist. My Discord can be found in the description of the video.

  • @hatty101
    @hatty101 4 года назад

    make it project a shoot/blast/bullet so it dmg the enemy pls

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      Finally got around to it. :)
      Part 3: ruclips.net/video/Yky0ON3wPS8/видео.html

    • @hatty101
      @hatty101 4 года назад +1

      @@CrazyCatDev thankssssssssssssssssssssssssssssssssssssssssssssssssss u are the best

  • @Fsoler97
    @Fsoler97 4 года назад +1

    I have copied everything and it does not work :(

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      Lo siento, no hablo español. Estoy usando Google Traductor. ¿Puedes describir el problema lo mejor que puedas? ¿Qué parte no funciona?

    • @Fsoler97
      @Fsoler97 4 года назад

      Does not detect collision

    • @Fsoler97
      @Fsoler97 4 года назад

      Nodes don't work

    • @Fsoler97
      @Fsoler97 4 года назад

      I have reviewed everything and it is the same as the tutorial

    • @CrazyCatDev
      @CrazyCatDev  4 года назад +1

      @@Fsoler97 If you would like, you can send your project to me and I'll take a look at it personally.
      If you use the 'zip up project' option in UE4 and upload the zip file to Dropbox / Google Drive , you can share it to me via the email address listed on my 'About' page.
      Alternatively, you can find me on Twitter (@CrazyCatDev2342) and send me a message with a link to your uploaded project. 😊

  • @PH0001
    @PH0001 4 года назад +1

    can you just put a link in description of project actually,we are in hurry :-)

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      There is a link to the project in the 3rd video: ruclips.net/video/Yky0ON3wPS8/видео.html

    • @PH0001
      @PH0001 4 года назад +1

      @@CrazyCatDev Thank you sir you helped us a lot

  • @sokol6876
    @sokol6876 3 месяца назад

    🙇🙇🙇🙇🙇

  • @LaFriteDuQC
    @LaFriteDuQC 4 года назад

    the turret is no longer the target. I send you everything

    • @CrazyCatDev
      @CrazyCatDev  4 года назад

      I received your email and have now replied. :)