Тёмный
No video :(

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

LegionGames
Подписаться 14 тыс.
Просмотров 90 тыс.
50% 1

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/Leg...
Assets:
Zombie model: www.mixamo.com/
Ground texture by 0melapics: www.freepik.co...
Kenney Graveyard Kit - www.kenney.nl/...
Wishlist Game: store.steampow...
Discord: / discord
Itch: legiongames.it...
Twitter: / legiongames1
Instagram: / legiongames1

Опубликовано:

 

23 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 374   
@NormalDalmatian
@NormalDalmatian 4 месяца назад
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 2 месяца назад
This comment should be pinned to top. Wasted 4 hours of googling just to stumble upon this comment
@IdenBond-xr1tj
@IdenBond-xr1tj Месяц назад
@@MaxSvid Exactly the same thing happened to me.
@okayoni6342
@okayoni6342 6 дней назад
For future readers, the video in question is the Complete 3D Shooting Mechanics video, and it's at 7:04 in that video. Huge thanks to @NormalDalmation for pointing this out.
@-starrysunrise-2908
@-starrysunrise-2908 Год назад
You can disable the movement in Mixamo itself, just check "in-place"
@legiongames2400
@legiongames2400 Год назад
Saves a lot of time! Thank you for pointing it out!
@TheRealAfroRick
@TheRealAfroRick 10 месяцев назад
I was just about to ask why this wasn't done as that resolves the root motion issue.
@eugeneivanov353
@eugeneivanov353 9 месяцев назад
Dude these tutorials are extremely good. You need to make more!!!
@legiongames2400
@legiongames2400 9 месяцев назад
Thank you! :)
@Yoni123
@Yoni123 6 месяцев назад
I didn't watch this yet but is it something that could beused for a stealth game? @@legiongames2400
@Failfer
@Failfer 7 месяцев назад
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 7 месяцев назад
Thank you for watching, I'm really glad it was helpful! :)
@runningwolfgames5955
@runningwolfgames5955 Месяц назад
@@legiongames2400any idea what could cause me to get an error in the zombie script on the line nav_agent.set_target_position(player.global_transform.origin) When I got to launch the debugger it crashes and says “Invalid get index ’global_transform’(on base: null instance’). Any help would be greatly appreciated🙏
@artiop7687
@artiop7687 Месяц назад
Incredible, thanks it helps me a lot and actually stills working on godot 4.2
@southparkfan4603
@southparkfan4603 Месяц назад
You're amazing, I was trying to figure this out for quite some time. Good video, keep up the good work, please :)
@tl3119
@tl3119 11 месяцев назад
@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 11 месяцев назад
Oh yeah thats a good idea! Thank you for watching!
@tl3119
@tl3119 11 месяцев назад
@@legiongames2400 Thank you for your video too, I learnt a lot from them!
@mamontain
@mamontain 9 месяцев назад
thanks
@tarik2662
@tarik2662 11 месяцев назад
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 11 месяцев назад
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 11 месяцев назад
@@paulchen9145 Set looping with script depending if player is in range or not, that way you will not cancel already playing Animation :)
@0kr4m
@0kr4m 6 месяцев назад
where is this?
@IceWolve67
@IceWolve67 6 месяцев назад
in the animation window, there is an icon you need to click, on the right of the name of the anim @@0kr4m
@noobnocontroletm3473
@noobnocontroletm3473 3 месяца назад
Thanks bro
@da_roachdogjr
@da_roachdogjr Год назад
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
@barney10240
@barney10240 3 месяца назад
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.
@TimberLine534
@TimberLine534 7 дней назад
Thanks man!
@FredyyDev
@FredyyDev 11 месяцев назад
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!
@JiKayPh
@JiKayPh 2 месяца назад
Nice! Looking forward to the next vids!
@andypandy-py1zc
@andypandy-py1zc 3 месяца назад
Absolutely brilliant tutorial, learnt some great code and ways to complete my game Thank you for sharing your knowledge.
@bongo6_462
@bongo6_462 Год назад
2:50 press reimport I believe if anyone is stuck. Really hopes this helps. Let me know, its my first day in Godot
@vettie
@vettie 11 месяцев назад
These are some of the best Godot tutorials that I've ever watched. Thanks alot.
@legiongames2400
@legiongames2400 9 месяцев назад
Thank you friend! :)
@DuhKoreGames
@DuhKoreGames 2 месяца назад
hey this is a great tutorial! just curious if you could explain/make a short video on adding visibility range to them, like they only notice you when you get a certain distance away, im struggling to understand how to implement it :((
@joelconstantine4105
@joelconstantine4105 7 месяцев назад
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 6 месяцев назад
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 5 месяцев назад
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 4 месяца назад
Same issue here
@gli7ch240
@gli7ch240 3 месяца назад
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
@Rawrqual
@Rawrqual 6 месяцев назад
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 6 месяцев назад
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 6 месяцев назад
I did that and still can't rename @@s1ndrome117
@stly8358
@stly8358 2 месяца назад
@@s1ndrome117 God Bless you
@kevinscott5899
@kevinscott5899 6 дней назад
@@s1ndrome117 thanks bro
@nicolaslanzoni9385
@nicolaslanzoni9385 4 месяца назад
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.
@slimebuck
@slimebuck 10 месяцев назад
this is perfectly what i need to do in my project. u sir came in clutch and saved the day!
@legiongames2400
@legiongames2400 10 месяцев назад
Glad I could help! :)
@indiegameworld5830
@indiegameworld5830 11 месяцев назад
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
@waldemarfernandesanhaya1618
@waldemarfernandesanhaya1618 3 месяца назад
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
@Shawn-cq7qy
@Shawn-cq7qy 7 месяцев назад
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 ❤
@diljotsahota9761
@diljotsahota9761 4 месяца назад
around 8 min mark - the animation of him running starts but does not loop - even though I have active turned on
@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: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-A3HLeyaBCq4.html
@ObrunoDF
@ObrunoDF Месяц назад
13:31 Hey bro, ah this part when we need to create this call method and the function hit doesn't appear. What can we do?
@btim8350
@btim8350 Месяц назад
you just have to save and itll show up
@PastaMaster115
@PastaMaster115 2 месяца назад
I don't know why yours works fine with your extra collision shape. For me the extra collision shape make it not work at all. Since I got an error for not having it, I added it back in but disabled it. It conflicts with the collision in the physical bones.
@IndiaMagicTV
@IndiaMagicTV 5 месяцев назад
Beautiful Zombies!
@PastaMaster115
@PastaMaster115 2 месяца назад
My code is exactly the same as yours but my zombie keeps on flying off to a corner of the map, never to be seen again. And then when I added the rotation code, then he started flying circles around me at light speed. And I flipped his mesh around, just for the sake of doing it, now he flies off to a completely different corner of the map. I even disabled the nav mesh just to see what would happen and he still flies away. Now matter how low I make his speed, he's still to fast. I even copied in code from another enemy tracking tutorial that worked in a different project. Still just flies off in whatever direction. Is something wrong with my level? Edit: So I made a test level to see what it would do and it did the exact same thing. So I looked to my Zombie scene. It seems that it was the extra capsule collision shape added before the physical bones were made. I deleted it and now it rotates when I move but it doesn't go anywhere. So I'm going to put your code back and see if I can manage to make him move. Then I can finally move on with this tutorial lol I rewrote your code and it works. Not sure how it was different from mine though. Anyway, time to finish this! lol
@runningwolfgames5955
@runningwolfgames5955 Месяц назад
I am having the same issue after I added the capsule shape my character wasn’t able to move what did u do to fix it?
@PastaMaster115
@PastaMaster115 Месяц назад
@@runningwolfgames5955 I kept the capsule but I disabled it.
@runningwolfgames5955
@runningwolfgames5955 Месяц назад
@@PastaMaster115when I do that it for some reason falls through the map🤷‍♀️😂
@victorgustavo4366
@victorgustavo4366 Месяц назад
7:24, my mob goes run off like as bullett. Why it does this? I have hatched 2 videos to solve this problem.
@s1ndrome117
@s1ndrome117 6 месяцев назад
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?
@queworldwow6262
@queworldwow6262 21 день назад
Thank you so much for this tutorial, it really helped! By the way, any idea how to make the enemy not jiggle when it comes to the edge of the navigation region? For some reason it freaks out when touches the edges of this area, it always moves at the speed of light and just rotates back-forth
@ropepores4688
@ropepores4688 Год назад
Thank you! Nice tutorial!
@legiongames2400
@legiongames2400 Год назад
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!
@user-mp2dx8kp4q
@user-mp2dx8kp4q Год назад
I like it, thanks for your tutorial!
@JustLis170
@JustLis170 4 месяца назад
THX BRO. You are te unique person that make good tutorials. I can't find tutorials like that in Spanish😭😭
@legiongames2400
@legiongames2400 4 месяца назад
Thank you friend! :)
@ThatAnimatorGuy_
@ThatAnimatorGuy_ 2 месяца назад
can you please make a video on ranged enemies? I'm making a movement based fps so it is really easy to dodge the melee enemies shown here. ty
@DanielAttaway
@DanielAttaway 5 месяцев назад
Very cool tutorial, thanks
@legiongames2400
@legiongames2400 5 месяцев назад
Thank you! :)
@paulchen9145
@paulchen9145 11 месяцев назад
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 11 месяцев назад
​@@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 11 месяцев назад
For me the problem was in looped attack animation.
@viquitorious
@viquitorious 11 месяцев назад
@@paulchen9145 @e-prophet4110 did you guys managed it?
@legiongames2400
@legiongames2400 9 месяцев назад
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) < 2 * ATTACK_RANGE return global_position.distance_to(player.global_position) < ATTACK_RANGE
@bonsaipropaganda
@bonsaipropaganda Год назад
So I'm stuck. when I try: "func target_in_range(): return global_position.direction_to(player.global_position) < attack_range" I get an invalid operands error: Invalid operands 'Vector3' and 'float' in operator '
@bonsaipropaganda
@bonsaipropaganda Год назад
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
@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?
@SylkieDev
@SylkieDev 2 месяца назад
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.
@user-zq6du5zo6c
@user-zq6du5zo6c 9 месяцев назад
I learned a lot! Thank you 🤓
@legiongames2400
@legiongames2400 9 месяцев назад
Glad it was helpful! :)
@graphtet3751
@graphtet3751 8 месяцев назад
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 6 месяцев назад
did you slide the player node in the player path variable from the zombie ?
@SparrowIZ
@SparrowIZ 3 месяца назад
@@IceWolve67 what you mean
@I_turnedLEFT
@I_turnedLEFT 9 месяцев назад
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 9 месяцев назад
Me 2 but somehow my other game nav sistem also not working
@runningwolfgames5955
@runningwolfgames5955 Месяц назад
Same here unfortunately😩
@sirpetrol7728
@sirpetrol7728 9 дней назад
@@runningwolfgames5955 did you find a solution?
@NatureValleyCrumbs
@NatureValleyCrumbs Год назад
Well done, great video!
@legiongames2400
@legiongames2400 Год назад
Thank you for watching! :) :)
@collinvisser7108
@collinvisser7108 Год назад
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 Год назад
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 Год назад
@@legiongames2400 Miziziziz and Canopy Games - but mainly the doc
@collinvisser7108
@collinvisser7108 Год назад
@@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 Год назад
@@collinvisser7108 Thank you, I still got ways to go.
@ince55ant
@ince55ant Год назад
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
@BESTIAL-CRUCIFIER
@BESTIAL-CRUCIFIER 6 месяцев назад
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 3 месяца назад
resolved?
@DeadByMonttt
@DeadByMonttt 5 месяцев назад
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 4 месяца назад
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) < 2 * ATTACK_RANGE return global_position.distance_to(player.global_position) < ATTACK_RANGE"
@DeadByMonttt
@DeadByMonttt 4 месяца назад
@@legiongames2400 thanks for your help
@sassani134
@sassani134 6 месяцев назад
Thanks a lot for this tuto
@entei6736
@entei6736 Год назад
dude you are a legend!
@jlebrech
@jlebrech Год назад
i would add a collision box to the zombie's hand and toggle the collider in the the animationplayer.
@Originalshy
@Originalshy 27 дней назад
I have a question! For the game I am making, the enemies do not have animations. Can I still detect the damage, and how?
@SunJaycy
@SunJaycy 6 месяцев назад
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" on the attack to running anim
@ThatAnimatorGuy_
@ThatAnimatorGuy_ 2 месяца назад
i'm getting that same issue but this isnt changing anything... can you give more detail?
@jasmansaharan2044
@jasmansaharan2044 Месяц назад
Anyone can please can help me that how did bro combined al the animations in blender in one as I am new in blender
@livvylowe8066
@livvylowe8066 Год назад
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 9 месяцев назад
Sir, your question is whether there is a misalignment of each collision bone when adding them to the zombie?
@PastaMaster115
@PastaMaster115 2 месяца назад
I'm so frustrated. I'm almost at the end of this tutorial. Things were rocky but I managed to get things to work for the most part. Except the zombie still floating above the ground when running but perfectly on the ground when attacking. And when attacking, won't do anything else until I get out of his attack range so he can run again. And on top of all of that, all the collision shapes somehow became catastrophically fucked. So I have to spend another hour placing them back where they go. I'm not having very good luck lol
@tutorial4779
@tutorial4779 10 месяцев назад
incredible wow.
@spud7234
@spud7234 8 месяцев назад
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 8 месяцев назад
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 8 месяцев назад
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
@davew723
@davew723 4 месяца назад
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 4 месяца назад
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.
@kultist_1810
@kultist_1810 Месяц назад
and why do I have a Zombie moving away from the player, and not towards him?
@bluethingy1112
@bluethingy1112 8 месяцев назад
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 8 месяцев назад
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 5 месяцев назад
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.
@icesin7084
@icesin7084 2 месяца назад
@@drilkus1312 Thanks mate u saved my ass
Год назад
Ty! Switching at end (attack) transition works if you disable attack animation loop from AnimationPlayer.
@paulchen9145
@paulchen9145 11 месяцев назад
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?
11 месяцев назад
@@paulchen9145 Switch to different animation like Idle after attack ends
@paulchen9145
@paulchen9145 11 месяцев назад
@ But that defeats the whole purpose right? Because I don't wanna play another animation like Idle but attack again straight away
@s3byn
@s3byn 10 месяцев назад
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.
@mr.someone.t4760
@mr.someone.t4760 8 месяцев назад
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 7 месяцев назад
@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 7 месяцев назад
@@dapro_bear8406 THANK YOU SO MUCH!!
@runningwolfgames5955
@runningwolfgames5955 Месяц назад
@@dapro_bear8406 I’m experiencing the same issue is there anyway could explain how to fix it better I’m extremely new. Like would I just need to remove the variable player = null?
@dapro_bear8406
@dapro_bear8406 Месяц назад
@@runningwolfgames5955 If you are still experiencing the same bug i had encountered, I believe that there is a very "fast segment" of the video where Legion Games assigns the player some sort of variable in a diffrent menu (I think by clicking on the left side of something) the timestamp that this happens is 6:24 (slow down the video and watch several times). Let me know if this helps!
@thebotheringguy2154
@thebotheringguy2154 28 дней назад
i am struggling with a problem: the switch mode seems to not work properly in godot 4.2 i also found on reddit people talking about this exact problem, they used to have the same working pattern of this zombie regarding animations and also the way to switch between animation, but as they update up to 4.2 (they used 4.0 initially) this happens: the switch mode "at the end" seems to not work properly, so we get the zombie stucked in the same position with attack looping as soon he match the range condition, before that he runs fine towards player, but after that he just stares you blocked in the same position with attack loop
@thebotheringguy2154
@thebotheringguy2154 28 дней назад
for now i solved the problem using "Xfade time" using also "immediate" switch mode, i gave 2 seconds to the animation to crossfade (which is nice cause the zombie slowly starting to run, kinda like more realistic acceleration) But still kindly asking to resolve the "at the end" problem :)
@BumpDev
@BumpDev 8 месяцев назад
Why do you use process and not physics_process? I'm confused
@aguest5394
@aguest5394 8 месяцев назад
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 7 месяцев назад
works fine for me
@juillotine
@juillotine Год назад
Thank you!
@legiongames2400
@legiongames2400 Год назад
Thank you for watching! :)
@JacobKinsley
@JacobKinsley Год назад
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?
@owenlloyd2528
@owenlloyd2528 Год назад
Thank you
@legiongames2400
@legiongames2400 Год назад
Thank you for watching! :)
@belgbeladel
@belgbeladel Год назад
very helpfull thank you so much
@legiongames2400
@legiongames2400 Год назад
Thank you :)
@sinsamuhamad
@sinsamuhamad 5 месяцев назад
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?
@ayotundealabi7843
@ayotundealabi7843 2 месяца назад
cool game engine
@Weebletmon
@Weebletmon Месяц назад
possibility of a updated tutorial?
@francoiscoetzee1381
@francoiscoetzee1381 2 месяца назад
Can you make an AI tutorial with path finding
@thricemindblown7883
@thricemindblown7883 9 месяцев назад
Any good alternatives to Mixamo? Makes me nervous relying on an Adobe resource.
@legiongames2400
@legiongames2400 9 месяцев назад
Not that I know of, but let me know if you find any good ones!
@melware_1869
@melware_1869 7 месяцев назад
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 6 месяцев назад
like he does just move forward to no end ?
@melware_1869
@melware_1869 6 месяцев назад
@@IceWolve67 yeah, and at lightspeed as well
@karimsantoro4326
@karimsantoro4326 Год назад
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 Год назад
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 Год назад
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 Год назад
@@karimsantoro4326 Yeah it's super buggy, I ended up having to attach the collision shapes manually. Check out this vid ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-6bbPHsB9TtI.html around 7:28 for a more in-depth process.
@davidmarinho2848
@davidmarinho2848 Год назад
@@legiongames2400 Thank u a lot! This was gold since I am new to this :)
@mrorange9127
@mrorange9127 5 месяцев назад
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 3 месяца назад
same issue occured with me, just set all skeletal bones collision layer to 2 as shown in video
@salt2947
@salt2947 9 месяцев назад
Everything is working but the collision shapes move out of place whenever the get up animation plays
@darxkl05
@darxkl05 Год назад
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
@rohitrana2312idk
@rohitrana2312idk Год назад
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: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-_4_DVbZwmYc.html Anyway thank you for watching :) Let me know if you have any other questions.
@rohitrana2312idk
@rohitrana2312idk Год назад
@@legiongames2400 Hey thanks, it did the work :)
@reliablespoon
@reliablespoon 2 месяца назад
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
@PastaMaster115
@PastaMaster115 2 месяца назад
I get that same error any time I try to do navigation meshes. I found out in a different tutorial that if you keep your code as is, and drop a zombie into your level and adjust the player path property, set it to player, it will work. Well sort of. I think it's meant to set that automatically when they spawn in on their own. But mine is sprinting off the damn screen when I enter the level.
@user-hv2qz5vi5f
@user-hv2qz5vi5f 3 месяца назад
Whenever I try spawning them in, they spawn with no AI and are twice as big. How do you fix this?
@MyntiAI
@MyntiAI Год назад
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 Год назад
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 11 месяцев назад
its still not working!@@legiongames2400
@artsmit9545
@artsmit9545 4 месяца назад
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
@ibluebee2832
@ibluebee2832 5 месяцев назад
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 4 месяца назад
I haven't done multiplayer with this just yet, I'm sorry
@ArrianeRanjikoAguilar
@ArrianeRanjikoAguilar 8 месяцев назад
what shortcut button did you use to put the files inside the duplicates to the other file?
@AneeshDogra
@AneeshDogra 5 месяцев назад
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 5 месяцев назад
move_and_slide multiplies velocity by delta so unless you're moving the character manually that's probably not the problem?
@MGenrl
@MGenrl 8 месяцев назад
I am having trouble getting my movement to work. Here's the code: extends CharacterBody3D var player = null const SPEED = 4.0 @export var player_path : NodePath @onready var nav_agent = $NavigationAgent3D # Called when the node enters the scene tree for the first time. func _ready(): player = get_node(player_path) # Called every frame. 'delta' is the elapsed time since the previous frame. 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() If you see any problems in the code, please tell me.
@soup_5268
@soup_5268 5 месяцев назад
same here i have no errors but my enemy is not moving at all
@Nelsonnumbertwo
@Nelsonnumbertwo 3 месяца назад
7:32 global_transform is invalid get index, null instance someone please help
@salvadormendiola2575
@salvadormendiola2575 3 месяца назад
nav_agent.set_target_position(player.global_transform.origin) is now nav_agent.target_position = player.global_transform.origin
@Lily-kv3rb
@Lily-kv3rb 3 месяца назад
@@salvadormendiola2575 I'm having the same error and this didn't fix it, any other ideas?
@cxsey8587
@cxsey8587 Год назад
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 Год назад
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 Год назад
@@legiongames2400 awesome !! Thank you!!
@brandonawstinks
@brandonawstinks 2 месяца назад
For some reason, my enemy just runs off the map as soon as the game starts at a very fast speed.
@brandonawstinks
@brandonawstinks 2 месяца назад
as an update. it is now in the sky.
@legiongames2400
@legiongames2400 2 месяца назад
Oh lawd. That is no good, could you double check where he's tryna go by printing his nav points?
@PastaMaster115
@PastaMaster115 2 месяца назад
I had the same problem. Then I added the rotation code and then he was spinning around me at light speed. And then spun fast enough to fly off like a helicopter.
@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? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0MHY2TDeMLM.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.
@ArrianeRanjikoAguilar
@ArrianeRanjikoAguilar 8 месяцев назад
idk why my 3d model gets bigger lying down and t posing when i delete the duplicate
@stevekonrad
@stevekonrad 8 месяцев назад
Weird... hitting x/del on 1:50 just deletes the rig on my end (blender 3.6.5)
@thoughtbrick709
@thoughtbrick709 6 месяцев назад
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 6 месяцев назад
i got the same problem, did you find a way to fix this?
@thoughtbrick709
@thoughtbrick709 Месяц назад
@@andinijor1812 yeah you need to enable the avoidance in the navigationagent3d then use the velocity_computed signal from it to move the character. Good luck
@yusifsayed8048
@yusifsayed8048 22 дня назад
2:50 it just doesn't work I'm working with 4.2
@Eternal_Night17
@Eternal_Night17 Год назад
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 9 месяцев назад
You need to move it with the animation player if you want it to move as well
@LadnoDev
@LadnoDev 7 месяцев назад
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 7 месяцев назад
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) < 2 * ATTACK_RANGE return global_position.distance_to(player.global_position) < ATTACK_RANGE"
@LadnoDev
@LadnoDev 7 месяцев назад
@@legiongames2400 Thanks! I'll try it out!
Далее
Complete 3D Shooting Mechanics - Godot 4 FPS Tutorial
12:14
Game Engine Of The Future
9:12
Просмотров 143 тыс.
OBLADAET - BARMAN
03:06
Просмотров 222 тыс.
Godot 4.3 is Here!
19:20
Просмотров 83 тыс.
How I made this battle scene in blender
11:05
Просмотров 334 тыс.
Creating SMART enemies from scratch! | Devlog
5:40
Просмотров 312 тыс.
Design 3D Game Levels From Scratch - Godot 4 Tutorial
11:04
Introduction To My Weird Shooter Game - Devlog 0
7:27
Просмотров 883 тыс.