3D Enemies With Pathfinding and Animations - Godot 4 FPS Tutorial

In this Godot 4 tutorial we create complex 3D zombie enemies for an FPS game. The covered topics include animations, pathfinding, attacking, detailed collision shapes, animation states using an AnimationTree, and spawning. These types of enemies can be used for a variety of first person games and third person games, including FPS, horror, survival, RPG, etc. All of this code works with Godot 4.1.
Support the channel: / legiongames
The project is available on Github: github.com/LegionGames/Zombie...
Assets:
Zombie model: www.mixamo.com/
Ground texture by 0melapics: www.freepik.com/free-vector/e...
Kenney Graveyard Kit - www.kenney.nl/assets/graveyar...
Wishlist Game: store.steampowered.com/app/21...
Discord: / discord
Itch: legiongames.itch.io/
Twitter: / legiongames1
Instagram: / legiongames1

Пікірлер: 330

  • @-starrysunrise-2908
    @-starrysunrise-290810 ай бұрын

    You can disable the movement in Mixamo itself, just check "in-place"

  • @legiongames2400

    @legiongames2400

    10 ай бұрын

    Saves a lot of time! Thank you for pointing it out!

  • @TheRealAfroRick

    @TheRealAfroRick

    7 ай бұрын

    I was just about to ask why this wasn't done as that resolves the root motion issue.

  • @andypandy-py1zc
    @andypandy-py1zcАй бұрын

    Absolutely brilliant tutorial, learnt some great code and ways to complete my game Thank you for sharing your knowledge.

  • @eugeneivanov353
    @eugeneivanov3537 ай бұрын

    Dude these tutorials are extremely good. You need to make more!!!

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Thank you! :)

  • @Yoni123

    @Yoni123

    4 ай бұрын

    I didn't watch this yet but is it something that could beused for a stealth game? @@legiongames2400

  • @Failfer
    @Failfer5 ай бұрын

    This is really nice thank you, I found other tutorials on AI Navigation but they all used the default capsule and didn't include the looking at part which I wanted to figure out, thank you

  • @legiongames2400

    @legiongames2400

    5 ай бұрын

    Thank you for watching, I'm really glad it was helpful! :)

  • @NormalDalmatian
    @NormalDalmatian2 ай бұрын

    For future viewers, if you notice that the auto-generated collisions for the skeleton don't stick to the model during animations it is addressed and fixed in the next video of this series! I'm talking about the collisions meant for bullet hits mentioned around 3:45

  • @MaxSvid

    @MaxSvid

    18 күн бұрын

    This comment should be pinned to top. Wasted 4 hours of googling just to stumble upon this comment

  • @JiKayPh
    @JiKayPh10 күн бұрын

    Nice! Looking forward to the next vids!

  • @da_roachdogjr
    @da_roachdogjr10 ай бұрын

    If after you make the enemy look at you and suddenly he's rotating but not moving, its because of the path height offset, I set it back to 0 and now it works. The setting is in NavigationAgent3D > pathfinding

  • @user-mp2dx8kp4q
    @user-mp2dx8kp4q9 ай бұрын

    I like it, thanks for your tutorial!

  • @bongo6_462
    @bongo6_46211 ай бұрын

    2:50 press reimport I believe if anyone is stuck. Really hopes this helps. Let me know, its my first day in Godot

  • @waldemarfernandesanhaya1618
    @waldemarfernandesanhaya1618Ай бұрын

    My zombie My zombie doesn't walk, can someone help me, I did everything said in the tutorial and it still didn't work, I tried other tutorials and it didn't work either, I'm starting to think that the problem is with the model or with the naviga agent

  • @ropepores4688
    @ropepores468811 ай бұрын

    Thank you! Nice tutorial!

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Thank you friend!!

  • @Shawn-cq7qy
    @Shawn-cq7qy5 ай бұрын

    Thx ❤the first time a watch it I didn’t do it right so I try a different video an then I come back to this video and restart it and it worked and I know now what I had done wrong and great video ❤

  • @FredyyDev
    @FredyyDev8 ай бұрын

    Hey, i'm not sure you know this but in 6:19 you could just export a node and use directly the same way you did there!

  • @user-zq6du5zo6c
    @user-zq6du5zo6c7 ай бұрын

    I learned a lot! Thank you 🤓

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Glad it was helpful! :)

  • @IndiaMagicTV
    @IndiaMagicTV3 ай бұрын

    Beautiful Zombies!

  • @tl3119
    @tl31198 ай бұрын

    @LegionGames The look_at flipped problem can actually fixed by setting the third argument (use_model_front) to true. According to the manual: If use_model_front is true, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).

  • @legiongames2400

    @legiongames2400

    8 ай бұрын

    Oh yeah thats a good idea! Thank you for watching!

  • @tl3119

    @tl3119

    8 ай бұрын

    @@legiongames2400 Thank you for your video too, I learnt a lot from them!

  • @mamontain

    @mamontain

    6 ай бұрын

    thanks

  • @DanielAttaway
    @DanielAttaway2 ай бұрын

    Very cool tutorial, thanks

  • @legiongames2400

    @legiongames2400

    2 ай бұрын

    Thank you! :)

  • @JasonRametta
    @JasonRametta Жыл бұрын

    Well done, great video!

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    Thank you for watching! :) :)

  • @sassani134
    @sassani1344 ай бұрын

    Thanks a lot for this tuto

  • @vettie
    @vettie9 ай бұрын

    These are some of the best Godot tutorials that I've ever watched. Thanks alot.

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Thank you friend! :)

  • @coltonrussell4110
    @coltonrussell4110 Жыл бұрын

    Yeah this is an Awesome video! I'd love it if you did some RTS style tutorials.

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    Thank you!

  • @entei6736
    @entei6736 Жыл бұрын

    dude you are a legend!

  • @slimebuck
    @slimebuck7 ай бұрын

    this is perfectly what i need to do in my project. u sir came in clutch and saved the day!

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Glad I could help! :)

  • @tarik2662
    @tarik26629 ай бұрын

    Nice one, you kind of forget to mention that you must enable looping in animation player in order for animations to actually loop.

  • @paulchen9145

    @paulchen9145

    9 ай бұрын

    But then the "AtEnd" transition from the attack-state back to the run-state will not happen right? Because the attack-animation is infinitely looping?

  • @tarik2662

    @tarik2662

    9 ай бұрын

    @@paulchen9145 Set looping with script depending if player is in range or not, that way you will not cancel already playing Animation :)

  • @0kr4m

    @0kr4m

    4 ай бұрын

    where is this?

  • @IceWolve67

    @IceWolve67

    3 ай бұрын

    in the animation window, there is an icon you need to click, on the right of the name of the anim @@0kr4m

  • @noobnocontroletm3473

    @noobnocontroletm3473

    Ай бұрын

    Thanks bro

  • @s1ndrome117
    @s1ndrome1174 ай бұрын

    hey! I wanted to ask why would you prefer to use _process() instead of _physics_process() for the enemy? shouldn't collision based bodies be in _physics_process() most of the time?

  • @tutorial4779
    @tutorial47798 ай бұрын

    incredible wow.

  • @indiegameworld5830
    @indiegameworld58308 ай бұрын

    I have subbed, because this isnt a copy and read, its an actual tutorial. Thanks alot, hopefullyi dont mess it up and blame it on the tutorial. And plus the get next path position has changed which makes previous tutorial sort of redundant

  • @livvylowe8066
    @livvylowe806610 ай бұрын

    Hi! I seem to be running into an issue with the AnimationTree Root Motion step, where setting the Root Motion track doesn't seem to lock it in place. I'm using the same mixamo animations as you but with a custom uploaded armature/mesh. Any ideas what could be the issue here? Thanks in advance. Edit: I just said screw it and redid the mixamo download with "in-place" checked

  • @redfun2125

    @redfun2125

    6 ай бұрын

    Sir, your question is whether there is a misalignment of each collision bone when adding them to the zombie?

  • @juillotine
    @juillotine10 ай бұрын

    Thank you!

  • @legiongames2400

    @legiongames2400

    10 ай бұрын

    Thank you for watching! :)

  • @barney10240
    @barney10240Ай бұрын

    During the "Attack < Run" animation in the "Switch" and subtab "Switch Mode," if you're on Godot 4.2+, don't bother to use "at The End"; instead, use "Immediate" for this tutorial.

  • @JStace
    @JStace4 ай бұрын

    my attack animation doesn't loop. and if I change the animation to loop in the editor then it doesn't switch back to run. fixed it. change the "at end" to "immediate"

  • @JacobKinsley
    @JacobKinsley10 ай бұрын

    Doesn't godot 4.0 have a way to directly import blender files so you don't have to mess with glb files and stuff?

  • @jlebrech
    @jlebrech Жыл бұрын

    i would add a collision box to the zombie's hand and toggle the collider in the the animationplayer.

  • @belgbeladel
    @belgbeladel11 ай бұрын

    very helpfull thank you so much

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Thank you :)

  • @owenlloyd2528
    @owenlloyd252811 ай бұрын

    Thank you

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Thank you for watching! :)

  • @ArrianeRanjikoAguilar
    @ArrianeRanjikoAguilar6 ай бұрын

    what shortcut button did you use to put the files inside the duplicates to the other file?

  • @BumpDev
    @BumpDev5 ай бұрын

    Why do you use process and not physics_process? I'm confused

  • @cxzv3
    @cxzv3 Жыл бұрын

    Ty keep it up can you make a video that tells how to do world generation

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    Thank you for watching! :) Like procedural generation?

  • @nicolaslanzoni9385
    @nicolaslanzoni93852 ай бұрын

    leaving a like to show my appreciation to the video, not because of how useful it was to me (it was) , but exclusively due to the fact he pronounces words with "L" as wittle baby would, which i find very cute.

  • 11 ай бұрын

    Ty! Switching at end (attack) transition works if you disable attack animation loop from AnimationPlayer.

  • @paulchen9145

    @paulchen9145

    9 ай бұрын

    But then the animation does not loop anymore right? So when the player just stands there the zombie should attack him multiple times, which is not happening when the animation does not loop?

  • 9 ай бұрын

    @@paulchen9145 Switch to different animation like Idle after attack ends

  • @paulchen9145

    @paulchen9145

    9 ай бұрын

    @ But that defeats the whole purpose right? Because I don't wanna play another animation like Idle but attack again straight away

  • @s3byn

    @s3byn

    8 ай бұрын

    Toggle the animation looping based on if the player is in range or not. When not in range, the zombie will finish its animation and return to his walking state because looping is disabled.

  • @salt2947
    @salt29477 ай бұрын

    Everything is working but the collision shapes move out of place whenever the get up animation plays

  • @sinsamuhamad
    @sinsamuhamad3 ай бұрын

    How can a distance parameter be established such that if a player is within one meter of a zombie, the zombie will start chasing, but if the player is farther away from the zombie, it will not chase?

  • @artsmit9545
    @artsmit95452 ай бұрын

    i have quarry , i made tps controller but it is not moveing in direction of camera faceing i can only go all direction (with animation) indipendent to camera can you help me i used same lerp logic and basic templet of charecter conreolled script

  • @Mr-Draxs
    @Mr-Draxs Жыл бұрын

    next video i recommend camera movement/reaction(camera shake). you know it shakes if moving right/left foward/backward(zoom in acording to speed) atacking/gettinghyrt(little shake in direction of atack, react to oposite direction of getting hurt) so many games forgot to add camera reaction when its something kinda simple and adds so much to immersion.

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    Thank you for watching! All of these things are already in this game, check out the character controller I used for it: kzread.info/dash/bejne/c2d8rseykaWpoZc.html

  • @JustLis170
    @JustLis170Ай бұрын

    THX BRO. You are te unique person that make good tutorials. I can't find tutorials like that in Spanish😭😭

  • @legiongames2400

    @legiongames2400

    Ай бұрын

    Thank you friend! :)

  • @BESTIAL-CRUCIFIER
    @BESTIAL-CRUCIFIER4 ай бұрын

    Hey man, this tutorial has been incredibly helpful to me. Can you offer any advice for making a range where the zombie doesn't pursue the player and instead idles/wanders? I tried but it didn't work, might be my misunderstanding of the animation tree.

  • @0xSuperMano

    @0xSuperMano

    27 күн бұрын

    resolved?

  • @diljotsahota9761
    @diljotsahota97612 ай бұрын

    around 8 min mark - the animation of him running starts but does not loop - even though I have active turned on

  • @joelconstantine4105
    @joelconstantine41055 ай бұрын

    I really appreciate the tutorials you've been having, all of this has been incredibly invaluable. However, I'm having some issues with this one and wondering if I missed anything. I'm on Godot 4.2. After following the tutorial up to the creation of the zombie script, everything seems to work fine, but when I test the my level scene to see how the zombie works, it moves around the map at an incredibly fast speed and has is not focused on the player at all. The zombie simply zooms around the map in random directions at high speed before it finally just falls off the end and disappears Total loss as to what is going on

  • @RdClZn

    @RdClZn

    3 ай бұрын

    Same here but I noticed it's going for the initial position of the player, it's as if the position and target are not getting updated at all

  • @mrorange9127

    @mrorange9127

    3 ай бұрын

    Any progress on this bug? I noticed that it is still doing the same thing after i deleted the script. It's probably due to the navigation agent.

  • @Pajusa101

    @Pajusa101

    2 ай бұрын

    Same issue here

  • @gli7ch240

    @gli7ch240

    Ай бұрын

    I had this same problem mine was because the collision shapes made for the sombie were on the same layer and mask as the world so they were infinitely colliding with each other pushing each other around change the masle and layer of each collision on the bones to a different one

  • @bonsaipropaganda
    @bonsaipropaganda10 ай бұрын

    So I'm stuck. when I try: "func target_in_range(): return global_position.direction_to(player.global_position) I get an invalid operands error: Invalid operands 'Vector3' and 'float' in operator '

  • @bonsaipropaganda

    @bonsaipropaganda

    10 ай бұрын

    nvm I'm silly haha I just needed to take a break and come back to it the next day and I immediately saw what I did wrong! I wrote direction_to instead of distance to

  • @ArrianeRanjikoAguilar
    @ArrianeRanjikoAguilar6 ай бұрын

    idk why my 3d model gets bigger lying down and t posing when i delete the duplicate

  • @paulchen9145
    @paulchen91459 ай бұрын

    I have a problem with the animation tree: When I switch the attack animation to "looping" the "at end"-transition from the attack state back to the run state is not working anymore. I guess this is expected, but it is important to have the attack animation looping, because when the player just stands still or stays in range of the player, the zombie should attack multiple times, so it should stay in the attack state. But I still want it to return to the run state once the player is out of range. I am guessing the "at end" transition never happens because a looping animation does not "end". How did you guys fix this?

  • @paulchen9145

    @paulchen9145

    9 ай бұрын

    ​@@e-prophet4110It's kinda weird because if you think about it wouldn't you be stuck in an animation state forever (like "attack") just because the animation is looping? Intuitively the "at end" transition should fire after every played animation and if the condition isn't met, it should loop again...

  • @user-qx1ff1pn1b

    @user-qx1ff1pn1b

    8 ай бұрын

    For me the problem was in looped attack animation.

  • @viquitorious

    @viquitorious

    8 ай бұрын

    @@paulchen9145 @e-prophet4110 did you guys managed it?

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Something I apparently hadn't noticed while I was making this. The animation can stay looping but the transition shouldn't be at end, it should be immediate. To give them a bit more range when they already started the attack I changed my target in range function to this: func _target_in_range(): if anim_tree.get("parameters/conditions/attack"): return global_position.distance_to(player.global_position) return global_position.distance_to(player.global_position) < ATTACK_RANGE

  • @spud7234
    @spud72346 ай бұрын

    Hey uh, how do i make the enemies not travel in a straight line? i.e avoid obstacles and follow the actual walkable path to the player in debug mode for the nav agent, the path even shows that it wants to go around obstacles and ramps is there some other way to write the walking code here?

  • @legiongames2400

    @legiongames2400

    6 ай бұрын

    I'm not fully understanding the question. The enemy pathing avoids obstacles and then travels in a straight line when that path is available, what kind of behavior are you looking for here?

  • @spud7234

    @spud7234

    6 ай бұрын

    I seem to be doing something wrong then, because mine does not avoid obstacles, I'll watch the vid more closely and see if it works, thanks

  • @darxkl05
    @darxkl0510 ай бұрын

    Even though I'm using godot 3.5 , you saved my fucking life. I had been struggling with smooth rotation for ages. Thanks a lot. Btw, I actually rotated the enemy through code, and this created a conflict with lerp so I just ended up removing the line that rotated the enemy and used the approach showed in the video (rotating the mesh). With both lines of code, the enemy just kept changing rotation every frame

  • @SylkieDev
    @SylkieDev4 күн бұрын

    Has anybody had issues running this in Godot 4.2.2 stable? I was having issues with the state machine not transitioning back to run, and so I downloaded the main project from github, it has the same issue. When they transition to the attack state they just stand still, and continue playing the attack animation.

  • @davew723
    @davew7232 ай бұрын

    Thanks for the video. It helped me get a FPS player controller going. For the enemy's why don't you use a hit box (area3d/collisionbox) to determine if there attack works. The range approach seems kind of scetchy.

  • @legiongames2400

    @legiongames2400

    Ай бұрын

    Thank you for watching! Yeah could be a little sketchy for some applications but it's worked okay for this kind of game. Probably wouldn't use it for anything but basic melee attacks.

  • @user-hv2qz5vi5f
    @user-hv2qz5vi5fАй бұрын

    Whenever I try spawning them in, they spawn with no AI and are twice as big. How do you fix this?

  • @reliablespoon
    @reliablespoon10 күн бұрын

    I keep getting the error "Invalid get index 'global_transform' (on base: 'null instance'). I don't know why this is. I did everything exactly as you did it in the tutorial

  • @Dankakes
    @Dankakes11 ай бұрын

    HIIII Can you show this with multiple platers? how to get the zombies to descide on a player to attack? Im thinking every 10 or so seconds it can determine the distance of each player and choose to path to the closest one (Via nav path so they dont try to go through walls)

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Hey thank you for watching! The game is unfortunately not made for more than one player so any video I make on this topic would have to be for a different game. But I think you're on the right track where you can get references to all player objects and for each zombie you would get the path to each player and check which one is shortest. You'd set that as your target and for next 10 seconds you'd be chasing that player.

  • @aguest5394
    @aguest53945 ай бұрын

    1:45 having trouble with this part, maybe maximo or the import has changed im not sure but i cannot just click delete not sure how/what to merge

  • @wannabeserpento99

    @wannabeserpento99

    5 ай бұрын

    works fine for me

  • @thricemindblown7883
    @thricemindblown78837 ай бұрын

    Any good alternatives to Mixamo? Makes me nervous relying on an Adobe resource.

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Not that I know of, but let me know if you find any good ones!

  • @stevekonrad
    @stevekonrad6 ай бұрын

    Weird... hitting x/del on 1:50 just deletes the rig on my end (blender 3.6.5)

  • @Robin_H.I
    @Robin_H.I10 ай бұрын

    I can not open the .GLB file into an new inherited space for some reason

  • @collinvisser7108
    @collinvisser710811 ай бұрын

    Neat well done - not sure if you did but using call deferred on hit and not calling it directly - my understand is this is performance - another small change is to use an area 3D on the player and on the enemy to control distance and link up the bools to the animation to area enter and area exist this can also have performance implications. distance_to is expensive to run every frame. Been enjoying this video

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Nice, thank you for the tips on performance, it's something that I really need to learn more about. Any resources that you used to figure all of this stuff out?

  • @collinvisser7108

    @collinvisser7108

    11 ай бұрын

    @@legiongames2400 Miziziziz and Canopy Games - but mainly the doc

  • @collinvisser7108

    @collinvisser7108

    11 ай бұрын

    @@legiongames2400 I am not an expert - You can see from my chanel and my itch I am doing basic stuff - I am not trying to use what the C++ code give and not codeing my own code - leverage the engine

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    @@collinvisser7108 Thank you, I still got ways to go.

  • @ince55ant

    @ince55ant

    9 ай бұрын

    you can do a cheaper distance_to by manually recreating it BUT not doing the square root part (a² + b² = c², with c being the distance and a & b being x/y/z, also remember to use absolute to get positive values). just need to note when making comparisons that the distance is squared, which you can just manually do, or multiply a variable by itself which is cheaper than the square root you'd otherwise have had to do

  • @Eternal_Night17
    @Eternal_Night1710 ай бұрын

    why when i play animation the Collision shape don't move with my zombie, like zombie moves with bones and bones collisions, but that one big circle just keep in one place when i play the animation.

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    You need to move it with the animation player if you want it to move as well

  • @cxsey8587
    @cxsey858711 ай бұрын

    If I wanted to have a more accurate damage model (e.g. heart, lungs, etc), could I place those within other collision shapes and check if the hit scan touches those to apply more damage?

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Yeah you can definitely do that as well! You would probably want to use a shape cast instead since a raycast can only collide with one collision area, but with a little bit of fine tuning shouldn't be too difficult to achieve! docs.godotengine.org/en/stable/classes/class_shapecast3d

  • @cxsey8587

    @cxsey8587

    11 ай бұрын

    @@legiongames2400 awesome !! Thank you!!

  • @ayotundealabi7843
    @ayotundealabi78435 күн бұрын

    cool game engine

  • @AneeshDogra
    @AneeshDogra3 ай бұрын

    Hey thanks a lot for the tutorials. I am using a different model and tried to follown along in the code for the zombie but for some reason my zombie just runs instantly to the player and then starts spinning. I think that: velocity = (next_nav_point - global_transform.origin).normalized() * SPEED should normalize the speed etc. but shouldn't we be taking delta into consideration here? I am running on 144 hz

  • @legiongames2400

    @legiongames2400

    2 ай бұрын

    move_and_slide multiplies velocity by delta so unless you're moving the character manually that's probably not the problem?

  • @bluethingy1112
    @bluethingy11126 ай бұрын

    Hey! Great Tutorial! Sorry I'm late, but I have a bug. Sometimes, when my zombie finishes its stand up animation, it will fly up into the air really fast. While it looks really funny in the game, I don't want it to happen. Could you help?

  • @legiongames2400

    @legiongames2400

    6 ай бұрын

    Had the same issue pop up but the problem for me was that the enemies were spawning on top of each other so I had to make sure to rotate the spawns. IDK if the same thing is causing it for you though.

  • @drilkus1312

    @drilkus1312

    2 ай бұрын

    I posted in another comment, but make sure your zombies Collision Mask is not the same as your worlds Collision Layer. Otherwise it can't find the correct path, so instead it rockets into the air.

  • @MyntiAI
    @MyntiAI11 ай бұрын

    For some reason there is an error for the code of the AI chasing the player. On the line "nav_agent.set_target_position(player.global_transform.origin)" it gives me an error. There are screenshots in the discord server for visual aid as I don't know how to explain it or even why something's wrong. Any help is appreciated :>

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Responded on discord but I think the issue is with how you're getting the player path using the editor like I did when I wasn't spawning the zombies. I eventually replaced that with just setting the path variable to the absolute path of the player directly: var player_path = "/root/World/Map/NavigationRegion3d/Player"

  • @CodeCanvasLabs

    @CodeCanvasLabs

    9 ай бұрын

    its still not working!@@legiongames2400

  • @HANDMEMY100
    @HANDMEMY1006 ай бұрын

    everytime i try to run my game it says “invalid get index global_transform (on base: null instance)” Any one know how to fix?

  • @dkiras193

    @dkiras193

    6 ай бұрын

    Me 2 but somehow my other game nav sistem also not working

  • @mrorange9127
    @mrorange91273 ай бұрын

    Hi Legion Games, the Zombie just moves at a very high speed in the player's direction and falls off the map after i enter the script in the video, are there any reasons to why this is happening?

  • @timepass6972

    @timepass6972

    24 күн бұрын

    same issue occured with me, just set all skeletal bones collision layer to 2 as shown in video

  • @melware_1869
    @melware_18695 ай бұрын

    for some reason when i followed until 7:00 everything was fine, but the move and slide function made my mesh just run into the void, had no way of changing where he went, was wondering if anyone has something similar happen to them?

  • @IceWolve67

    @IceWolve67

    3 ай бұрын

    like he does just move forward to no end ?

  • @melware_1869

    @melware_1869

    3 ай бұрын

    @@IceWolve67 yeah, and at lightspeed as well

  • @DeadByMonttt
    @DeadByMonttt2 ай бұрын

    in godot 4.1.3 when the attack animation is in loop we can't make the State_machine to go back to "Run" with "at_the_end" if we don't loop the "Attack" animation the enemy just hit you once and stand there how can i solve this problem ?

  • @legiongames2400

    @legiongames2400

    2 ай бұрын

    Something I apparently hadn't noticed while I was making this. The animation can stay looping but the transition shouldn't be at end, it should be immediate. To give them a bit more range when they already started the attack I changed my target in range function to this: func _target_in_range(): if anim_tree.get("parameters/conditions/attack"): return global_position.distance_to(player.global_position) return global_position.distance_to(player.global_position) < ATTACK_RANGE"

  • @DeadByMonttt

    @DeadByMonttt

    2 ай бұрын

    @@legiongames2400 thanks for your help

  • @karimsantoro4326
    @karimsantoro432610 ай бұрын

    Hi i have a problem with my animation tree: from run to attack it' s all right but I have noticed that the enemy character, does not continue to attack either if my player is still in range. the enemy remain stopped until I move my player. I have tried loop animation for the enemy smash but in that way, the animation tree remains always in the smash animation. Could someone help me to understand better the problem? thanks

  • @legiongames2400

    @legiongames2400

    10 ай бұрын

    That's my fault, sorry! My knockback hits the player out of range so I never noticed this was an issue! At the end of the enemy process function remove anim_tree.set("parameters/conditions/run", !_target_in_range()) and add anim_tree.set("parameters/conditions/run", true) to the ready function.

  • @karimsantoro4326

    @karimsantoro4326

    10 ай бұрын

    i feel like a fool. I should have thought about it. thanks anyway. But do you too godot 4.1.1 have problems in collisions of physical bones? if I start an animation after setting the statemachine those collisions scatter by themselves

  • @legiongames2400

    @legiongames2400

    10 ай бұрын

    @@karimsantoro4326 Yeah it's super buggy, I ended up having to attach the collision shapes manually. Check out this vid kzread.info/dash/bejne/aJaWsqqscpy6pKw.html around 7:28 for a more in-depth process.

  • @davidmarinho2848

    @davidmarinho2848

    10 ай бұрын

    @@legiongames2400 Thank u a lot! This was gold since I am new to this :)

  • @jkasar
    @jkasar11 ай бұрын

    I'm having an issue where my enemy character's rotation is snapping to the directions it is navigating towards. For example if I jump on a ledge, it will quickly snap to the direction of the path it has chosen. What do you think could be causing this? Here the walk state code I'm using. match state_machine.get_current_node(): "Walk": nav_agent.set_target_position(player.global_transform.origin) var next_nav_point = nav_agent.get_next_path_position() velocity = (next_nav_point - global_transform.origin).normalized() * SPEED look_at(Vector3(global_position.x + velocity.x,global_position.y,global_position.z + velocity.z), Vector3.UP)

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    Yeah the snapping is ugly that's why at around 19:30 I change that last line to lerp the rotation towards where they're going a little slower.

  • @jkasar

    @jkasar

    11 ай бұрын

    @@legiongames2400 I didn't watch all the way! 😭Sorry, thank you!

  • @legiongames2400

    @legiongames2400

    11 ай бұрын

    @@jkasar Haha, no worries :D

  • @ketziel_
    @ketziel_7 ай бұрын

    I can't seem to change the animation names. I enable "Save to file" in the advanced import settings, and then am able to rename all of the animations. But when I save, and reopen the scene, the names have all returned to what they were before. Any ideas on what I've missed?

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    I forgot to edit that into the video apparently but you also need to make sure to click reimport after you tick save to file on all the meshes

  • @Legit_SuperFall

    @Legit_SuperFall

    5 ай бұрын

    After messing with this for a long time, i can't get it to work unless i use blender. It worked in version 4.3.1 when i first started, but it doesn't anymore in any version.

  • @Rawrqual
    @Rawrqual4 ай бұрын

    Not sure if it's a bug in Godot 4.2, but I couldn't rename my animations no matter what settings I pressed. I had to eventually go and re-name them inside Blender instead.

  • @s1ndrome117

    @s1ndrome117

    4 ай бұрын

    it got changed in 4.2, now you have to create a inherited scene, save it, then remove inheritance by right-clicking on the root node inside the saved scene

  • @0kr4m

    @0kr4m

    4 ай бұрын

    I did that and still can't rename @@s1ndrome117

  • @ibluebee2832
    @ibluebee28322 ай бұрын

    Hey Legion ! I'm doing a multiplayer game where the players are spawned, so i can't use player_path the same way you did, do you have any idea on how to solve this problem ? the players name aren't player1 and player2, they are 1 for the host and random numbers for the clients. thanks for the tutorial !

  • @legiongames2400

    @legiongames2400

    2 ай бұрын

    I haven't done multiplayer with this just yet, I'm sorry

  • @graphtet3751
    @graphtet37516 ай бұрын

    When it try to add the enemy to the scene and run it it crashes and displays the text “invalid get index global transform on base null instance” how do I solve this

  • @IceWolve67

    @IceWolve67

    3 ай бұрын

    did you slide the player node in the player path variable from the zombie ?

  • @SparrowIZ

    @SparrowIZ

    Ай бұрын

    @@IceWolve67 what you mean

  • @RealJesus
    @RealJesus8 ай бұрын

    Yo bro is there anyway to make the enemy stand still when he can't reach the player? Because he just starts glitching out.@LegionGames

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Yeah make the movement conditional on finding a viable path to the player

  • @RealJesus

    @RealJesus

    6 ай бұрын

    @@legiongames2400thanks👍👍

  • @WilliamAdelstein
    @WilliamAdelstein8 ай бұрын

    anyone else getting invert: Condition"det == 0" is true ? my debugger is just spamming this all the time with my enemy.

  • @Willty64
    @Willty6411 ай бұрын

    for some reason, my Enemy doesn't switch to his attacking animation. I can force it to play in the Animation Tree, and my code looks the same as yours, but I just cant get it to work in-game.

  • @Willty64

    @Willty64

    11 ай бұрын

    Found the error. I cant believe it. I spelled parameter as "paramater". Anyways, thanks for the video, very informative.

  • @gli7ch240

    @gli7ch240

    3 ай бұрын

    Thank you so much I was stuck on this for hours it is crazy how something can go so wrong from a simple missing letter😂

  • @LanceMyair
    @LanceMyair8 ай бұрын

    is there a way to turn the enemy around in the look at function with code? The root bone also got animated by mixamo.

  • @LanceMyair

    @LanceMyair

    8 ай бұрын

    I put this line after the lookat: self.rotate_object_local(Vector3(0,1,0), 3.14)

  • @samaluh

    @samaluh

    7 ай бұрын

    @@LanceMyair dude ty this was so helpful

  • @LanceMyair

    @LanceMyair

    7 ай бұрын

    @@samaluh yeah I think I will try to sum up everything I find in my Blogposts on Twitter and on my channel. Glad I could help 😃

  • @Viltzuxxx-zu6nd
    @Viltzuxxx-zu6nd5 ай бұрын

    idk why but when i delete the other models and go to animation it only plays the one that the model i didnt delete had

  • @legiongames2400

    @legiongames2400

    5 ай бұрын

    This is in Blender or Godot?

  • @LadnoDev
    @LadnoDev5 ай бұрын

    Hey man, I finished the turorial but there is a problem. If you stand still, and the zombie attacks, the zombie freezes after attack finishes. Do you have an idea how to fix that?

  • @legiongames2400

    @legiongames2400

    5 ай бұрын

    Hey this is an issue someone else noticed too, if you want to see the full discussion look for the comment by paulchen 9145. But this was my response to it: "Something I apparently hadn't noticed while I was making this. The animation can stay looping but the transition shouldn't be at end, it should be immediate. To give them a bit more range when they already started the attack I changed my target in range function to this: func _target_in_range(): if anim_tree.get("parameters/conditions/attack"): return global_position.distance_to(player.global_position) return global_position.distance_to(player.global_position) < ATTACK_RANGE"

  • @LadnoDev

    @LadnoDev

    5 ай бұрын

    @@legiongames2400 Thanks! I'll try it out!

  • @rc8s
    @rc8s7 ай бұрын

    how come I don't see "New Inherited Scene," and where is it now if it's been moved?

  • @rc8s

    @rc8s

    7 ай бұрын

    it fixed itself

  • @MiniKam
    @MiniKam10 ай бұрын

    I'm getting Function "move_and_slide()" not found in base self, and I don't know why

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Make sure that the base node is a CharacterBody3D and that the first line of the script says "extends CharacterBody3D"

  • @jubibi390
    @jubibi3909 ай бұрын

    hello!! for starter. i copied your code specifically in this part: extends CharacterBody3D var player = null const SPEED = 4.0 @onready var player_path : NodePath @onready var nav_agent = $NavigationAgent3D func _ready(): player = get_node(player_path) func _process(delta): velocity = Vector3.ZERO nav_agent.set_target_position(player.global_transform.origin) var next_nav_point = nav_agent.get_next_path_position() velocity = (next_nav_point - global_transform.origin).normalized() * SPEED move_and_slide() but i got an error that says: Invalid get index 'global_transform' (on base: 'null_instance'). I'm stuck. please help ahuhu

  • @xakuma0913

    @xakuma0913

    9 ай бұрын

    Player_path is null / wrong it cant find the player

  • @rorrust2110

    @rorrust2110

    2 ай бұрын

    yeah i got that same issue. if you put the Player node inside of the NavigationRegion3D node with the enemy, it should work fine.

  • @thoughtbrick709
    @thoughtbrick7093 ай бұрын

    Amazing tutorial on pathfinding but you are have not addressed one issue. All the enemies can overlap which means there is no distance between them and all of them are in the same position. Is there a possible solution to this problem?

  • @andinijor1812

    @andinijor1812

    3 ай бұрын

    i got the same problem, did you find a way to fix this?

  • @mischiefunmanageable
    @mischiefunmanageable Жыл бұрын

    Can you please make a video on how to load another scene in this 3D Game (like accessible house or next levels)?? PS. Subbed :)

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    I can just explain it for now. Right click on the player in the editor and click save branch as scene. Then once you have a player scene in the files just drag it into a different level you want to enter into. Figure out where you want the level transition to be in the map and put an Area3D there to check if a player entered it with a signal. Once the player enters that area call this line of code: get_tree().change_scene_to_file("res://Scenes/YourNewLevel.tscn"). And bam you're in a new level. If you want to get fancy you can even add a transition to it like this: kzread.info/dash/bejne/kWiTpribitrTicY.html Anyway thank you for watching :) Let me know if you have any other questions.

  • @mischiefunmanageable

    @mischiefunmanageable

    Жыл бұрын

    @@legiongames2400 Hey thanks, it did the work :)

  • @spideyempire4110
    @spideyempire41102 ай бұрын

    Bro please help me when I import gbl object like curve wall to my project i don't show any texture or color how to fix it (please reply this time)

  • @legiongames2400

    @legiongames2400

    2 ай бұрын

    It looks like they don't work out of the box anymore. The asset pack has a file called colormap.png under the texture folder, make sure to import that into your project and drag it into the surface material override on the mesh

  • @spideyempire4110

    @spideyempire4110

    2 ай бұрын

    @@legiongames2400 can I get your insta I'd please so you can show me through a video cause I m new to this engine

  • @spongobongo9011
    @spongobongo90119 ай бұрын

    ..just osom!

  • @smartntboy2474
    @smartntboy24749 ай бұрын

    How can I make it so they face in the direction they’re walking like in unturned

  • @thotwire

    @thotwire

    7 ай бұрын

    did you ever figure this out?

  • @mr.someone.t4760
    @mr.someone.t47605 ай бұрын

    Great video and series! I just have a problem when copy and paste the zombie I get a debug error saying: Invalid get index 'global_position'(on base: 'null instance"). This error is occurring on the _target_in_range(): part, and _process part. I even tried to copy paste your code form the git hub, since I am relatively new in godot so I must have made a mistake, but I still get the same error message. How to fix please help??!!

  • @dapro_bear8406

    @dapro_bear8406

    5 ай бұрын

    @mr.someone.t4760 After wayyyyy too much time for such an easy thing to fix, I discovered at 6:24 through 6:29 that Legion Games assigns the player_path to the actual player (it's null by default) by clicking on the zombie in the explorer then clicking the player path and then clicking the actual player on the UI that pops up. In this case, there is a "null instance" because the script is trying to move the zombie to something that doesn't exist using a node/variable that isn't assigned to anything. Despite the fact that it has been two weeks, hopefully this helped.

  • @mr.someone.t4760

    @mr.someone.t4760

    5 ай бұрын

    @@dapro_bear8406 THANK YOU SO MUCH!!

  • @PavMTG
    @PavMTG5 ай бұрын

    I'm having issues with my collision shapes in the skeleton following the animation transform changes (e.g. if my enemy is standing up at start then crawls, the collision shapes will be still in the position when the enemy was standing). It seems also they collision shape position is set to wherever I left the frame in the animation player before hitting play. Anyone know how to fix this?

  • @PavMTG

    @PavMTG

    5 ай бұрын

    ok figured it out. you need to change the physical bone nodes to a bone attachment 3d and it works!

  • @PavMTG

    @PavMTG

    5 ай бұрын

    Apologies, you have to parent the physical bone 3d to the bone attachment 3d node.

  • @kardrasa

    @kardrasa

    3 ай бұрын

    Hey thanks that seems to have fixed it! I did have to reposition everything which sucked

  • @Eternal_Night17
    @Eternal_Night1710 ай бұрын

    why the zombie is without skin, I selected that I want' to download it with skin and it is still without it

  • @Eternal_Night17

    @Eternal_Night17

    10 ай бұрын

    Oh i needed to select the character :DDD sorry

  • @Betegfos
    @Betegfos7 ай бұрын

    How can I make it so, that the player loses health when hit by the enemy? Should it be controlled by a game manager script?

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    Have a health variable on the player & subtract from it whenever the player is hit.

  • @Betegfos

    @Betegfos

    7 ай бұрын

    @@legiongames2400 Thanks. That makes sense. But how do I differentiate between enemy types regarding their attack damage?

  • @legiongames2400

    @legiongames2400

    7 ай бұрын

    @@Betegfos if you're calling a hit function on the player from the enemy then you can add a damage parameter to the function. Then just pass however much damage this specific enemy does to the player so they can subtract it from their health.

  • @ivailoburov1295
    @ivailoburov1295 Жыл бұрын

    Thanks for sharing. I'm interested in a similar solution, using a RigidBody for the zombie - there are still no such examples.

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    Thank you for watching. Rigidbodies are not really intended for use with characters, they are used for props or other things that need a physics simulation. From the Godot documentation: "This is the node that implements full 3D physics. This means that you do not control a RigidBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.". The fact that you have to apply forces for the body to move as opposed to just setting the velocity and moving them makes it very janky to work with. No real reason to reinvent the wheel.

  • @ivailoburov1295

    @ivailoburov1295

    Жыл бұрын

    @@legiongames2400 Yes, however I see similar functionality in modern games - for example, a character hitted by a car or an explosion.

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    @@ivailoburov1295 Yeah the easiest way to achieve that is to replace the character with a ragdoll when it dies, which is what most games do.

  • @ivailoburov1295

    @ivailoburov1295

    Жыл бұрын

    @@legiongames2400 There's an example of an active Ragdool for Godot on youtube, but I'm still not sure it's the solution for eg a car collision.

  • @legiongames2400

    @legiongames2400

    Жыл бұрын

    @@ivailoburov1295 You're talking about this one? kzread.info/dash/bejne/YoF8u5SNdMizfLA.html Really freaking cool stuff and probably could be a good start depending on what you want to do. Like you said out of the box it won't work with a car collision because I assume you want your character to go flying after it gets hit by a car but the ragdoll there is still attached to a character body which just doesn't move like that. You could maybe disable all of the physics stuff he is doing to keep all of the ragdoll bones attached to the base animation to let it fly off after being hit.

  • @jakehudson9118
    @jakehudson91184 ай бұрын

    followed along right to the end but am having trouble with the enemies spawning and following the player. i changed the script so that the enemy uses the players node path but for some reason the spawned enemies wont chase the player. extends CharacterBody3D var player = null const SPEED = 4.0 @export var player_path := "/root/World/Map/NavigationRegion3D/Player" @onready var nav_agent = $NavigationAgent3D func _ready(): player = get_node(player_path) func _process(_delta): velocity = Vector3.ZERO nav_agent.set_target_position(player.global_transform.origin) var next_nav_point = nav_agent.get_next_path_position() velocity = (next_nav_point - global_transform.origin).normalized() * SPEED look_at(Vector3(player.global_position.x, global_position.y, player.global_position.z), Vector3.UP) move_and_slide() i know this is unlikely to get a response but thank you in advance hopefully :)

  • @cogomelo9912
    @cogomelo99126 ай бұрын

    i have a problem, the enemy just goes and points toward the players initial position, what do i do?

  • @vaskebjorn_

    @vaskebjorn_

    6 ай бұрын

    I am currently having the same problem...

  • @vaskebjorn_

    @vaskebjorn_

    6 ай бұрын

    Hey I fixed it on my end, my root node for my player was not the CharacterBody3D, (I used a regular node 3D instead and made everything the child of it.) When I made the CharacterBody3D the new root node it fixed the problem for me. My guess is the Zombie was tracking the position of the Regular Node3D and not the CharacterBody3D, and switching them out caused it to track properly. If this doesn't work idk what will... Goodluck!