How to Make an Enemy AI Using Behavior Trees in Unreal Engine 5 #2 - Attack Player

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 108

  • @ZimCrusher
    @ZimCrusher ปีที่แล้ว +21

    you are one of the clearest teachers ever.
    Love you, man

    • @GorkaGames
      @GorkaGames  ปีที่แล้ว +3

      thank you so much!! I really appreciate it!

    • @thomashealy5990
      @thomashealy5990 ปีที่แล้ว

      @@GorkaGames
      trying this as a reply so you might actually see it.
      you didn't tell us how to make the AI roam around again after its done attacking if i die and respawn or if i leave and re enter nav mesh the AI stays still and is only able to damage me when directly in front of it. it will not resume chase nor roam around. the commenters solutions have not fixed this for me.

  • @killerthepro756
    @killerthepro756 ปีที่แล้ว +8

    will you expand this series to at least 7 or 8 more episodes to the series talking about it more and how you can use it like some shooter AI or a Horror AI that hunts you down i would love to see it

  • @arthurmarquis764
    @arthurmarquis764 ปีที่แล้ว +2

    Awesome video tutorial @Gorka Games, but how would I set an attack speed that can be modified on the instance of the AI that would update the task? I am struggling.
    I tried this:
    1. In your Blueprint EnemyAI, create a new public variable that you want to share with your Blackboard task.
    2. In your AI controller blueprint, add a new "Blackboard Component".
    3. In the "Blackboard Component" settings, create a new "Object" key called "Enemy AI".
    4. In your "Event Begin Play" event of your AI controller blueprint, get a reference to your Blueprint EnemyAI and set it to the "Enemy AI" blackboard key.
    5. In your Blackboard task, use a "Blackboard" node to access the "Enemy AI" key.
    6. In the "Blackboard" node settings, set the "Object Type" to your Blueprint EnemyAI class.
    7. Use a "Get Actor" node to get a reference to your Blueprint EnemyAI from the "Enemy AI" key.
    8. Use a "Cast To" node to cast your reference to your Blueprint EnemyAI class.
    9. From the "As [Blueprint EnemyAI]" output, you can access the public variable and use it in your task.

  • @joeyfromthefuture
    @joeyfromthefuture ปีที่แล้ว +3

    I really appreciate your video style man - you actually explain the 'why' behind things and I'm finally learning rather than just copying. I am having an issue with one part though, I can't get the AI's attack delay to work and it continuously spams the attack. I have tried several different methods but all I've attempted either broke the attack or did nothing to solve the issue..

  • @CheshireTheLiar
    @CheshireTheLiar ปีที่แล้ว +8

    Everything is working great except if I break the line of sight, the enemy AI won't return to roaming around or chasing the player again if they see them. Any suggestions?
    Love your videos and clear instructions. Your making dreams come true!

    • @3DChaddd
      @3DChaddd ปีที่แล้ว +1

      I managed to remedy this by copying and pasting another "Set Value As Bool" at the end of the "On See Pawn" Event with a 3 second delay between them. Make sure to set the Second "Set Value as Bool" to False (Uncheck the bool value) and the AI will go back to Roaming around after 3 seconds of not seeing the player.

    • @cyberdesigner2724
      @cyberdesigner2724 ปีที่แล้ว +1

      @@3DChaddd Can confirm that this works well as long as you use a Retriggerable Delay node.

  • @theempireofstud
    @theempireofstud ปีที่แล้ว +4

    Yay a new video and it is very interesting!

    • @GorkaGames
      @GorkaGames  ปีที่แล้ว +2

      💯 I'm glad you like my videos!

  • @chameleonedm
    @chameleonedm ปีที่แล้ว +1

    Those discord noises had me checking my own discord, probably not the intended effect. Thanks for the tutorial though

  • @Pwnclips
    @Pwnclips ปีที่แล้ว +1

    I used a pimp slap zombie anim that takes a few from start to finish so i moved your delay over and put it between "Attack Player' & "Finish Execute" which solved the delay the ai had to began starting the attack and starting the 2nd attack.

  • @giftheck
    @giftheck 4 หลายเดือนก่อน

    This has been very helpful! Any chance you could add a part 3, showing us how to make an enemy that can do both ranged and close attacks? IE like a shooter that shoots at distance but then punches you when you're close?

  • @wolfiedgr8t
    @wolfiedgr8t ปีที่แล้ว +3

    Great stuff man, thanks. I love your tutorials ❤

    • @GorkaGames
      @GorkaGames  ปีที่แล้ว +2

      thank you as always!!

  • @krasnavin
    @krasnavin ปีที่แล้ว

    Excellent tutorial. I enjoy hearing your comments. Adding to my new game.

  • @Im_Derivative
    @Im_Derivative 3 หลายเดือนก่อน

    Do you have a simple tutorial for damaging the AI back? I am using a custom spawner to spawn multiple AI that I can battle, and it works great, but I cannot damage them yet. Trying to come up with a simple solution for now.

  • @PlayItAgainGames2023
    @PlayItAgainGames2023 ปีที่แล้ว +2

    everything works but the AI gets stuck in attack player if you get away from them and then go back. Also if they get stuck on a wall the AI just stops and doesn't move again.

  • @BigDaddyZhandt
    @BigDaddyZhandt ปีที่แล้ว +1

    After applying the Animation Montage, I checked to see if it worked. The AI character chases me, hits me once and then just stands there. If I move, he will move. If I run away, he will chase me and hit me only once when catching up to me. Any ideas on how to fix this? All help is appreciated.

  • @Pwnclips
    @Pwnclips ปีที่แล้ว

    Would have loved for more advance ai stuff.

  • @rideaway40
    @rideaway40 ปีที่แล้ว +1

    is there a free punch animation or something i can use for my game?

  • @IN-terestShorts
    @IN-terestShorts ปีที่แล้ว +1

    AI animation tutorial please

  • @rankot399
    @rankot399 หลายเดือนก่อน

    how do I make a mission where I chase the enemy along a pre-defined path, where the enemy jumps over obstacles and runs?

  • @kryogenicgames
    @kryogenicgames ปีที่แล้ว +1

    nice one, very handy

  • @heavenseek
    @heavenseek ปีที่แล้ว +1

    MAGNIFICENT!!

  • @GrimsinxGaming
    @GrimsinxGaming ปีที่แล้ว

    Thank you bro for this your ledgend I just started using ue5 got most of it down packed but your tutorials help so much keep it up bro💯💯🇦🇺

  • @XPol555
    @XPol555 ปีที่แล้ว +1

    18:25 he flew away!! :D

  • @CrimysteryMate
    @CrimysteryMate 9 หลายเดือนก่อน

    hey man, i appreciate your efforts for this video. just a quick question can you please tell me how can i disable those path lines that is coming out from the enemy while running?

  • @DigeL-el6uo
    @DigeL-el6uo ปีที่แล้ว

    Really good and helpful videos :) Thank you!

  • @AliBounds
    @AliBounds ปีที่แล้ว +1

    Awesome video

  • @uchihakidd9026
    @uchihakidd9026 ปีที่แล้ว +4

    yeah i dunno why but my sphere trace doesn't appear on my enemy. it runs up as normal but no green and red line to indicate that its doing anything. The visiblity is one so i dont know whats happening with it

    • @uchihakidd9026
      @uchihakidd9026 ปีที่แล้ว +2

      I actually fixed it myself I'm proud lol. Apparently, all I needed to do was switch the simple parallel function in the behavior tree to a sequence in case anyone else has issues with it as well

    • @raregodb
      @raregodb ปีที่แล้ว +1

      @@uchihakidd9026 dont u know why parallel func doesnt work properly? it fixed my issue too, but its strange

    • @LaceUpBrah
      @LaceUpBrah ปีที่แล้ว +1

      You fucking legend, I tried that myself but it didn't work because I had to switch the attack player on the left side & chase on the right side but your comment made me give it another try and it worked!

    • @austinwhiteted8231
      @austinwhiteted8231 4 หลายเดือนก่อน +2

      I found out clicking on the paralell you can switch it from immediate execution to after and it works!

    • @uchihakidd9026
      @uchihakidd9026 4 หลายเดือนก่อน +1

      @@raregodb im still trying to understand behavior trees, but the fact that a small change like that worked is insane to me

  • @sirmanbeard910
    @sirmanbeard910 ปีที่แล้ว +1

    Hey brother, question. Can you just duplicate this AI to make multiple of them chasing and attacking you? If so, how? I have it setup but once a second one gets to me, none of them attack anymore. Ideas?

    • @jeromeb7973
      @jeromeb7973 ปีที่แล้ว

      I put a "get player charecter" and plugged one into the "Get actor Location" and one into to "get actor rotation" and it worked for me.

  • @heavenseek
    @heavenseek ปีที่แล้ว +3

    Thanks! I'm on your Discord, now too. May I submit a proposal for some specific tutorials towards a basic mixed genre game? I'll send you an outline and I believe these would add nicely to your existing channel playlists, so everyone on here can benefit from some slightly different logic / actions that other channels don't explore (involving vehicle interaction, swapping characters, etc).

    • @GorkaGames
      @GorkaGames  ปีที่แล้ว +1

      Thank you so much for your support again Heavenseek!! I really appreciate it 🙏 Absolutely, I would love to hear more feedback on how I can improve! Now that you mention it, yeah it would be really cool to have vehicle interaction tutorials etc. Looking forward into making those soon!

    • @heavenseek
      @heavenseek ปีที่แล้ว +2

      @@GorkaGames Yes, my pleasure! This project is one storyline that uses bits / mechanics from gta, horror, managing companion morale, and combat. Each bit can be super basic for now. It would just be fascinating to access such different actions from one story - hub.
      Viewers could customize the setup to fit their own ideas / genres.
      I'll provide all assets/ fbx's that you may need...
      I can send the outline, if you like, and discuss payment for each tutorial

  • @mate1_dev
    @mate1_dev ปีที่แล้ว

    How to make it so that on lost focus the AI will just switch to its original task? My AI just stands there when its not in the range of the pawnsensing and I already checked everything like 3 times

  • @beachsberiding2370
    @beachsberiding2370 ปีที่แล้ว

    How would you make the AI start to roam again after losing sight of the player? I saw someone comment that you can copy the "Set Value as Bool" node and paste it at the end and put a retriggerable delay between the two nodes. No matter what I tried, this did not work, and my AI still followed the player infinitely.

  • @traincontain8778
    @traincontain8778 28 วันที่ผ่านมา

    how do i make it that i can see the sphear traceres when im playing.

  • @yessnowww5345
    @yessnowww5345 ปีที่แล้ว

    great man !! 👌✌ Thx for tutoriels

  • @trayvonray9614
    @trayvonray9614 ปีที่แล้ว

    Great video

  • @Periland2
    @Periland2 ปีที่แล้ว +1

    Amazing Video loved it works all good but how do i make the circles dissapear in game and how do i make him to start roaming around after he stops seeing me

    • @Periland2
      @Periland2 ปีที่แล้ว +1

      also after he gets to the random point in radios he just stands there forever until he sees a player how do i make him patrol forever until he sees someone instead of doing it once and standing still

  • @Birdscolony211
    @Birdscolony211 6 หลายเดือนก่อน

    How to make him fight with us only when we start the fight first ? Else he will be normal npc

  • @ClassicJoog
    @ClassicJoog ปีที่แล้ว

    Could you make one of these for when the ai is attacking with a gun or grenade??

  • @meesheuij
    @meesheuij ปีที่แล้ว

    soimeonbe able to help me ?, my simple parralel does not work. when i try with one task at the time it works but when its in the paralel the atack does nothing

  • @bluegizmo1983
    @bluegizmo1983 ปีที่แล้ว

    AI behavior trees?! ... I haven't even figured out regular trees yet! 😂

  • @imkeyi
    @imkeyi ปีที่แล้ว

    I have a death sequence in animation blue print, i find out that if my character killed the AI while AI in attacking montage, the AI will finish the attacking montage then play death animation, how do i set the AI instant die even in attacking montage pls?

  • @blacktecno
    @blacktecno 8 หลายเดือนก่อน

    Just in case someone can help me, Ive got a pawn cube which I want to be attacked by the AI. The AI does chase it, but it fails to cast to the BP Box (the pawn) to later play the attack animation (or do any damage afterwards). If I make the animation play on failed cast it does play once, but never repeat.

  • @alefet.8861
    @alefet.8861 ปีที่แล้ว

    Amazing Tutorial.
    Still a bit strange how sometimes the AI takes time to attack the player i.e. at first sight if the player runs at the AI, but still great video!

  • @Mbb2220
    @Mbb2220 ปีที่แล้ว +1

    Thanks alot!!!!!

  • @magegames6202
    @magegames6202 ปีที่แล้ว

    can you do a tutorial covering if you thow a grenade and kill multi enemies it conts the kill count it only works for my bullets rn

  • @magnificunt
    @magnificunt 10 หลายเดือนก่อน

    For some reason when the enemy is attacking, my editor freezes, but from the audio I can still hear I'm walking around.

    • @magnificunt
      @magnificunt 10 หลายเดือนก่อน

      Nevermind, the issue was the Sphere Trace for Objects, I changed the debug mode to none and now it's fine.

  • @girlx7706
    @girlx7706 ปีที่แล้ว

    Why don't you use Notify?

  • @notgamingwithfaz
    @notgamingwithfaz 9 หลายเดือนก่อน

    When I leave the area by going up high like jumping up on a platform it breaks and the ai won’t move after that can anyone help me

  • @elijahpm
    @elijahpm ปีที่แล้ว

    Can i control the area of damage? i think it is a little too big

  • @timboslice5351
    @timboslice5351 ปีที่แล้ว

    Hey Gorka! Amazing stuff as always. Everything works as it should, but I was wondering how you would go about multiple enemies? I work with an Enemy Wave Spawner and my two enemy types are accidentally dealing damage to each other, cause they're all pawns. Am I missing something? Thx in advance

    • @The1111Dark
      @The1111Dark ปีที่แล้ว

      Run a check on the class of the pawn being hit, if it's not the player's class then don't deal the damage

  • @B31L
    @B31L ปีที่แล้ว +1

    cool 👍👍👍👍

  • @hoodeez
    @hoodeez 9 หลายเดือนก่อน

    5:19 there is no break option on my end and i replay every step so that im doing exactly what youre doing in the video but my ue5 is probably a newer update since this is over a year old

    • @RileyMacfarlane-cg3or
      @RileyMacfarlane-cg3or 8 หลายเดือนก่อน

      I am having the same issue! Did you manage to sort this?

    • @SpicyBandit_tv1
      @SpicyBandit_tv1 3 หลายเดือนก่อน

      @@RileyMacfarlane-cg3or Well boys??

    • @SpicyBandit_tv1
      @SpicyBandit_tv1 3 หลายเดือนก่อน

      Fixed this and hope you did too!

  • @sisitech
    @sisitech ปีที่แล้ว

    Everything works when I put the Delay duration on under 0,4, but when I put it on 1 second the entire attack system just stops working. Doesn't make any sense to me

    • @sisitech
      @sisitech ปีที่แล้ว

      To make it even weirder, when I put the damage on 0, the enemy will attack me multiple times when standing still. But when I put it any higher than 0, it will only attack me once and then stop.
      I have no idea how to fix it, because there doesnt seem to be any logic behind it.

  • @jbober123
    @jbober123 ปีที่แล้ว

    But how to turn again Roam Around?

  • @tableshoe7776
    @tableshoe7776 ปีที่แล้ว

    How do I remove the Green spheres after I'm done using it?

    • @cyanwaffles
      @cyanwaffles ปีที่แล้ว

      turn draw debug type to none

  • @madeeasy7148
    @madeeasy7148 ปีที่แล้ว

    AI is hell to implement

  • @realleglesslizard
    @realleglesslizard ปีที่แล้ว

    where can I get the animation for attacking?

    • @BerserkDestroyer
      @BerserkDestroyer 6 หลายเดือนก่อน

      mixamo lol

    • @realleglesslizard
      @realleglesslizard 6 หลายเดือนก่อน

      @@BerserkDestroyer thanks lmao (i quit game making like 6 months ago)

  • @johndoe35717
    @johndoe35717 ปีที่แล้ว

    the zombie is so easy to break, jump and it stops following you and just stands there

  • @gameflix7510
    @gameflix7510 ปีที่แล้ว +1

    👌👍👍✌

  • @QuadDamage3
    @QuadDamage3 4 หลายเดือนก่อน

    While video is nice as always, actual resulting AI is godawful. I wish you'd put more thought and care into this.

  • @lukagamer2011
    @lukagamer2011 ปีที่แล้ว

    Bro you can to make really good game for this and you can to be to popular because you can to make game this is not easy but you know how to make and this is to good

    • @Theshadowclaw3000
      @Theshadowclaw3000 ปีที่แล้ว +1

      what are you smoking bruh ?

    • @Periland2
      @Periland2 ปีที่แล้ว

      @@Theshadowclaw3000 xDDD

  • @chrisslender8385
    @chrisslender8385 6 หลายเดือนก่อน

    Not working

  • @kIDNEYKid-xt9uc
    @kIDNEYKid-xt9uc ปีที่แล้ว

    my AI stays in idle when it gets close to me. anyone else having this problem?

    • @lilbon6073
      @lilbon6073 ปีที่แล้ว

      same, did you solve it?

    • @kIDNEYKid-xt9uc
      @kIDNEYKid-xt9uc ปีที่แล้ว

      @@lilbon6073 my particular issue was having 2 character meshes in the character blueprint.

    • @francoiscaillaud5275
      @francoiscaillaud5275 ปีที่แล้ว

      same problem here, did you find a solution?

    • @kIDNEYKid-xt9uc
      @kIDNEYKid-xt9uc ปีที่แล้ว

      @@francoiscaillaud5275 do you have 2 meshes in your bot's blueprint?

    • @francoiscaillaud5275
      @francoiscaillaud5275 ปีที่แล้ว

      @@kIDNEYKid-xt9uc yes it’s a metuhuman BP

  • @Titan-xx1zn
    @Titan-xx1zn ปีที่แล้ว

    Not sure if there were any recent updates but when I setup the simple parallel, only the left branch of chase player gets run even if the AI is standing and facing the player. Followed the steps in both tutorials and not sure how to get the right branch to fire for attacking. I did try changing the finish mode on the parrel to 'Delayed' and that seem to work only for the AI to get stuck attacking even if the player moves away. Anyone else run into this issue?

    • @Titan-xx1zn
      @Titan-xx1zn ปีที่แล้ว +1

      I got rid of the simple parallel and it works fine just going off chase player sequence, for anyone else!

    • @thecodingkeet
      @thecodingkeet ปีที่แล้ว

      This helped alot thanks! @@Titan-xx1zn