AI spawner for Lyra : teams, pawn data and how to make them fight in UE5! NPC spawning Part 1

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ค. 2024
  • I've been wanting to add AI/NPC to my project for a while and finally figured out a solution that works for me! I wanted to share here my knowledge and how Lyra handles AI spawning and pawn data in general.
    This is a part 1 or 3, I'm planning on covering creating an NPC only team in the next one then how to spawn lyra character with abilities that don't have a PlayerState in the next. Game on!
    Part 2 at : • Create teams for NPC :...
    Part 3 at : • NPC Spawner Part 3 : B...
    Github code at : github.com/NanceDevDiaries/Tu...
    Project used: Lyra Sample project 5.2
    Engine used : Unreal Engine 5.2
    Shoutout to this amazing video to help me figure out my audio settings : • The Loudness Secret to...
    Join my Patreon to get video credits and if you'd like to give thanks!
    / nancedevdiaries
    Thanks for watching!
    ---------------
    Timestamps:
    00:00 - Intro
    02:09 - How spawning AI works in Lyra
    10:33 - C++ for spawning AI : Spawner and logic to get the Pawn Data
    18:42 - Setup the spawner and data in BP and DataAssets
    33:09 - Outro, closing thoughts

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

  • @nancedevdiaries
    @nancedevdiaries  27 วันที่ผ่านมา

    I have fixed the issue where the clients don't respawned and updated the github code! Took me a little while but was very satisfying to see Clients respawning! Here's the commit with the changelist (just moved 2 lines) github.com/NanceDevDiaries/Tutorials/commit/d0fb0db0bc420204bd0e00b112adc1c312740e1d

  • @afootgames
    @afootgames 11 หลายเดือนก่อน +1

    I spent a good 6 hours a few weeks back working through all that code trying to figure out how to spawn increasing amounts of AI in waves. Gave up... so thankful you make videos for us, you're amazing!

  • @quinton_d
    @quinton_d 3 หลายเดือนก่อน +1

    Amazing as always! Best Lyra tutorials on the internet

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

    Great video!!! Before I found this video I was struggling to figure out how to give non player actors different abilities. Creating the NPC opens up so many possibilities. I'm not talented in C++ but understand it enough to not blow up the project when trying to follow along. Thank you!!

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

    another W from you, so glad I discovered Lyra and your channel

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

    Thank you for sharing this! Exactly what I was looking for 🎉

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

    This is another amazing tutorial! Thank you for sharing!

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

    OMG, I am creating a project with Lyra which i spawn zombies and shoot them, always had hard times spawning zombies for different team & include them in lyra framework. That is very useful.

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

    I was trying to do this by changing the OnChoosePlayerStart and ServerChooseTeamForPlayer.
    But your solution was much better. Thanks.

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

    That's great! Hope to make more videos~

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

    I also went through adding NPCs for my game and it made me feel stupid taking so long doing it. Lyra has so many systems dependencies and it's easy to get lost. As always, you break it down so nicely :)

    • @nancedevdiaries
      @nancedevdiaries  11 หลายเดือนก่อน +1

      Thank you for the support and kind words!! It also took me a whole lot of time. I am looking forward to recording/sharing the next 2 parts :)

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

    ur like a legend now

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

    BRILLIANT, I tried creating NPC’s with logic however I could not set them into their own team. This should work well in one of my new game modes.(edited)

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

    Nance is the GOAT!!!

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

    Awesome ^_^

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

    thank you.

  • @austinscottful
    @austinscottful 11 หลายเดือนก่อน +1

    Thanks!🎉

    • @nancedevdiaries
      @nancedevdiaries  11 หลายเดือนก่อน +1

      Thanks for the support!

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

    Old dog learning new tricks here, thanks to your awesome videos. It's like a Lyra Missing Manual. I did find an issue with your implementation where (human) player 2 does NOT respawn on death, though NPC players do. Thanks!

    • @nancedevdiaries
      @nancedevdiaries  9 หลายเดือนก่อน +1

      Thanks for the support! I'm happy to share what I find!
      I'll check it out with 2 player controlled pawns. I only have the full project from the 3 videos. Maybe part 2 or 3 has a solution, I'll update when I get to it. Cheers, and thanks again!

    • @nancedevdiaries
      @nancedevdiaries  27 วันที่ผ่านมา

      I have fixed the issue and updated the github code! Took me a little while but was very satisfying to see Clients respawning! Here's the commit with the changelist (just moved 2 lines) github.com/NanceDevDiaries/Tutorials/commit/d0fb0db0bc420204bd0e00b112adc1c312740e1d

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

    This is very helpful, thank you!!

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

    I gotta say: good stuff!
    Anyway, I've looked over your code and I have some questions here and there if you may answer :).
    1.In the NPCSpawner you have a list of Controllers and you have a comment regarding "pooling the controllers". What do you mean by that? You want to keep the initially created controllers and changed them around when an NPC dies, right? So, you have Controller1 for NPC1 and when NPC1 dies, you want to use the same Controller1 in order to not create a new Controller for it.
    2.Theres a comment regarding SpawnAIFromClass in which you state that you can make a new static function in UAIBlueprintHelperLibrary. Now, I'm not so sure but, isn't UAIBlueprintHelperLibrary part of the Engine? If it is, is it a good practice to change Engine code? :-?
    Thanks a lot for the tutorial!

    • @nancedevdiaries
      @nancedevdiaries  27 วันที่ผ่านมา +1

      Thanks! I don't think anymore that there's much upside to pooling the controllers, but I haven't tried it myself. As for the static function, it would be good to add to and make your game's own AI blueprint helper library, you're right, best not to modify engine code :).

  • @MrGhayma-arabic
    @MrGhayma-arabic 11 หลายเดือนก่อน

    Good

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

    Hey, good video can u maybe show later how we add Nvidiareflex and DLSS to the game settings ?

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

    Should we remove B_BotSpawner from the experience's component? I mean the Lyra's BotSpawner component. I didnt see we have removed in the video or not

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

    Hi Nance, first and foremost, thank you for your insightful tutorials; they have undoubtedly been beneficial to many, including myself!
    I have a couple of queries that I'm hoping you might be able to help with.
    Performance Lag with Multiple Characters:
    I've noticed a significant drop in performance when using multiple characters in a scene. Even on high-end hardware like an RTX 4090, the lag is quite noticeable. There's also a discussion on the Unreal Engine forums regarding this issue: Many Lyra Characters Cause Massive Lag Even on RTX 4090. Have you encountered this problem, and if so, do you have any optimization tips?
    Customizing "Common Maps" in Toolbar:
    I have been trying to figure out how to add or remove maps from the "Common Maps" section in the toolbar, but I haven't been able to find this information via search. Do you happen to know how this can be done?
    Your insights on these matters would be highly appreciated.

    • @case384
      @case384 11 หลายเดือนก่อน +1

      Have you tried this in a packaged build? It makes a huge difference when you have multiple AI characters compared to in editor. I'm able to get 60-70 FPS on a 3080 TI, high settings, 1440p with 60 AI attacking me with melee and magic attacks simultaneously (on a blank map). I'm also using AI Optimizer from the unreal marketplace, allows you to disable tick, animations, AI controller, despawn after a certain distance or hide meshes when not looking at them. Makes a big difference also.

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

      Thanks! The common maps can be found and edited via the editor settings > Lyra developer settings > maps > common maps.
      I have a video about Lyra dev settings here, but it was before the common map update that might still be useful to you! th-cam.com/video/UEWU6dlfKiM/w-d-xo.htmlfeature=shared.
      I don't have any optimizing tips for characters yet, I don't use too many Lyra characters on screen at once :). I did notice a hitch when selecting a LyraCharcter in the outliner. I'm curious about that. I will share if I do find some more info! Cheers

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

    The hero I spawn does not take any damage? :/ help.
    I also just duplicated the shooter mannequin and changed its mesh. But it just does not listen to any damage event.

  • @VideosFavero
    @VideosFavero 10 หลายเดือนก่อน +1

    Just so you know, these changes work in 5.3, I just tested it.

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

      Thank you! Good to know

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

    I just want to create Bot spawner that does everything the same, as in Continue to be the default Lyra Bots. And Ignore whatever custom character the player is.. Also I am not a c++ programmer and didnt understand what you did @8:50 to switch from the header file to the CPP file?

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

      I'm using a shortcut Alt-O to swap between header (.h) and body (.cpp). If that doesn't work for you, they're in the same folder and you can access them in your explorer.

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

    I'm having a problem with multiplayer - client does spawn initially but does not re-posess once killed - it looks like client stays in spectator mode. Any ideas @nancedevdiaries?

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

      Actually, this fix seems to work - maybe you can confirm it's a safe solution? ** LyraPlayerState.cpp >> Do not omit anything from ALyraPlayerState::PostInitializeComponents()

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

      Hey Roja! I've been meaning to look into the client respawn issue for a while. I did get some awesome support through email, I should soon have time soon enough to test the solution(s) and share :).
      I'll have to follow my own tutorial videos as it's been a while for this one haha

    • @nancedevdiaries
      @nancedevdiaries  27 วันที่ผ่านมา

      I have fixed the issue and updated the github code! Took me a little while but was very satisfying to see Clients respawning! Here's the commit with the changelist (just moved 2 lines) github.com/NanceDevDiaries/Tutorials/commit/d0fb0db0bc420204bd0e00b112adc1c312740e1d

  • @JoeGameDevWorkspace
    @JoeGameDevWorkspace 9 หลายเดือนก่อน +1

    A Bug At 29:28 ,Client 1 player spawn without mesh and anything else ,but i can see health bar

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

      I have this problem, seems to only do it on DebugGame mode using rider. Still havent figured out how to solve it. Seems the client's Player controller gets lost just after 'unpossess'. Did you ever solve it?

    • @nancedevdiaries
      @nancedevdiaries  27 วันที่ผ่านมา

      I have fixed the issue and updated the github code! Took me a little while but was very satisfying to see Clients respawning! Here's the commit with the changelist (just moved 2 lines) github.com/NanceDevDiaries/Tutorials/commit/d0fb0db0bc420204bd0e00b112adc1c312740e1d

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

    Not Sure Why but when trying to create the bot spawner from the NPCSpawner its no showing up . Infact Nothing I create from the c++ class does?.
    Also when VS Builds I get these errors.
    Error C2027 use of undefined type 'ULyraPawnData' LyraVR D:\UnrealEngine\UE_5.2\Engine\Source\Runtime\CoreUObject\Public\Templates\Casts.h 250
    Error C2338 static_assert failed: 'Attempting to cast to an incomplete type' LyraVR D:\UnrealEngine\UE_5.2\Engine\Source\Runtime\CoreUObject\Public\Templates\Casts.h 250

    • @nancedevdiaries
      @nancedevdiaries  10 หลายเดือนก่อน +1

      Just missing an include, thats probably why it's not compiling. Here's the commit from Leandro (thank you!) at github.com/NanceDevDiaries/Tutorials/commit/d64dffc6550b52582e8bc1eac53fdc51554f17db. Thanks I'll make sure to remove the commit link from the video so people don't miss that line.

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

      Thanks I was trying this on My custom Lyra project , but I just started a fresh one from scratch and Everything worked perfectly . Im going Migrate my Lyra plugin to a working version of this new one.@@nancedevdiaries

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

    I've tried multiple times and followed the instructions perfectly but I'm getting build failed with 13 errors every time. is there any chance you could post a base project with everything working to OneDrive so we can just download it??
    im trying to make a zombie wave game and this seems like the best way to do it.
    love the videos btw. keep up the good work!

    • @nancedevdiaries
      @nancedevdiaries  9 หลายเดือนก่อน +1

      Thanks! I just tried with a fresh 5.2 Lyra Sample Project the section "C++ for spawning AI : Spawner and logic to get the Pawn Data" and was able to run and compile. Differences might be the Lyra engine version or iteration's code you might be using? The project is really big, and if I were to share all the "Source" folder it might just make it more confusing and not clear what code this tutorial deals with amongst all the Lyra code. I hope it works for you soon!