Juiced Up First Person Character Controller Tutorial - Godot 3D FPS

  Рет қаралды 163,138

LegionGames

LegionGames

Жыл бұрын

In this video we create a first person character controller for Godot 4 from scratch. We also add a range of game feel features including headbob, sprinting, fov change, and inertia. This controller can be used for a variety of Godot 3D first person games, including FPS, horror, survival, RPG, etc. All of this code works with Godot 4.1.
Support the channel: / legiongames
The full project is available on github: github.com/LegionGames/FirstP...
Godot 3D transforms explained: docs.godotengine.org/en/4.0/t...
Wishlist Game: store.steampowered.com/app/21...
Discord: / discord
Itch: legiongames.itch.io/
Twitter: / legiongames1
Instagram: / legiongames1

Пікірлер: 640
@legiongames2400
@legiongames2400 Жыл бұрын
As badunius pointed out, a capsule shape is better for collision because it is a simpler shape. When you're creating a collision shape make sure to use that. This has been updated on github. Also make sure to turn on collisions for any CSG boxes you add or you will fall through the floor.
@tftc97
@tftc97 11 ай бұрын
where do i do that???????????????????????????? edit: nvm
@kinggreen9073
@kinggreen9073 11 ай бұрын
I said the same thing bro@@tftc97
@Kirico_gd
@Kirico_gd 10 ай бұрын
hey do you still reply under older videos, if yes do you know why my camera moves on both x and y axis when i load the game
@sourlesscream1272
@sourlesscream1272 10 ай бұрын
@@Kirico_gd Head pivot is for horizontal rotation and Camera is for vertical the camera portion of the script should look like this head.rotate_y(-event.relative.x * SENSITIVITY) camera.rotate_x(-event.relative.y * SENSITIVITY) camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-45), deg_to_rad(45))
@dynstinn
@dynstinn 9 ай бұрын
can you add crouching please, i need this character controller for a horror game im making, i REALLY need crouching
@pixels_per_minute
@pixels_per_minute 3 ай бұрын
One of the best First Person tutorials I've ever found for Godot. A LOT of other videos seem to throw out the sample code for far more complex code that just dose the same basic stuff in a different way. I like how you just build off it instead, and provided us with a simple, yet highly configurable base. I also learned a few tricks I can apply in my 2.5D character controller since it also uses the same sample code. From here, I'll be looking to add in a raycast system in order to see what the player is looking at and maybe a menu system, which I now know how to do thanks to people like you!
@legiongames2400
@legiongames2400 3 ай бұрын
Thank you friend! :) I'm really glad I get to help out
@badunius_code
@badunius_code Жыл бұрын
0:45 technically capsule collision shape gotta be better for perfomance, because you have to solve just one primitive collision, whereas a convex hull is solved on per face basis.
@legiongames2400
@legiongames2400 Жыл бұрын
Oh yeah that actually makes sense.
@deadturret4049
@deadturret4049 9 ай бұрын
way better for performance. You could argue that the capsule is calculating 3 shapes, (2 spheres, 1 cylinder), but the calculations to do those is ludicrously simple and fast. Switching to face collisions is not great.
@Spuds1411
@Spuds1411 4 ай бұрын
I've always just used a cylinder for character collisions! I've found its the simplest possible shape which also gives the best results for collisions!
@BurritoByte
@BurritoByte 7 ай бұрын
Hello LegionGames! I wanted to thank you for creating this video. I recently wrapped up my Godot 4 FPS prototype and this video played a monumental role in getting the initial player controller implemented and working for my project. I just published my video of it on my page and have added you in the game's credits as a thank you for this tutorial video. Thanks so much again and looking forward to future uploads!
@legiongames2400
@legiongames2400 7 ай бұрын
Thank you friend! :) I'm really glad it helped you out!
@yusarimahubara
@yusarimahubara 9 ай бұрын
The best simple head bob I could found in the internet, the other ones are overcomplicated and they didn't seem so nice, great job!
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you! :)
@DePistolero
@DePistolero 5 ай бұрын
YES, elegant, simple, tweakable, straightforward and bulletproof... Just starting godot( turnover from Unity ) more than 7 yrs of xp...
@Papajoofable
@Papajoofable Ай бұрын
​@@legiongames2400Hey man! Cool vid, i really like that headbob. But, how can i make footsteps sounds with it? (I hate animation player and blend tree headbobbing)
@menacingskull740
@menacingskull740 Ай бұрын
THE POWER OF ACTUALLY USING MATH AND ACTUAL FUNCTIONS IN GODOT
@ScratchyBlade7634
@ScratchyBlade7634 28 күн бұрын
i cant get it working and my camera is jsut stuck halfway in the floor for some reason
@wolcamophone4783
@wolcamophone4783 Жыл бұрын
I find it easier to pull better snippets of code and explanations from random tutorial vids than to watch tutorials on specific subjects as some tutorials will mislead you from what you want to actually accomplish in your code.
@dapperwolf465
@dapperwolf465 9 ай бұрын
Wait
@dapperwolf465
@dapperwolf465 9 ай бұрын
HOLD ON YOU GAVE ME A IDEA!
@spinnysponk778
@spinnysponk778 9 ай бұрын
@@dapperwolf465what js ur idea
@bamb00zld
@bamb00zld 8 ай бұрын
Says the intermediate programmer who probably knew Python before learning Godot.
@steviewonderisnotblind5833
@steviewonderisnotblind5833 3 ай бұрын
@@bamb00zld flexing your credentials on a tutorial video is pretty embarrassing
@jasonleeroberts
@jasonleeroberts 2 ай бұрын
this was amazing. incredibly fast, and concise. thank you! for any new game devs like me who couldn't figure out the collision at the beginning of the video: Just click CSGBox3D, and in the CSGShape3D menu on the right, click the checkbox next to "Use Collision". Make sure to do this for the other boxes you make for the level too. You can CTRL+click all the boxes you want to add collision to and add it to all of them at once.
@jaythewolf7216
@jaythewolf7216 3 күн бұрын
big help thank you. i was going through and adding a collision node to everything lol
@MizziePeasy
@MizziePeasy 2 ай бұрын
I am starting now on the game dev world and this was the first video I found that didn't bore me to death! Straight to the point and great humour! I was planning on doing a single player arena shooter and you have the perfect video. Thank you so so much, I really hope you have lot of success in your life ☺
@Marcusvlogs
@Marcusvlogs 2 ай бұрын
Really good tutorial. I like that it was fast and informative but didnt get bogged down into every little gritty detail
@Dawid30303
@Dawid30303 10 ай бұрын
great tutorial, thanks a lot. To anyone new to godot, if you are confused about what a function is doing, then i recommend printing out the variable the function is modifying. This helped me understand a few things a bit better
@legiongames2400
@legiongames2400 10 ай бұрын
That's a great idea even if you're not new to godot haha, thank you for watching!
@indieology7336
@indieology7336 Жыл бұрын
This is awesome! Thank you for your great work!
@legiongames2400
@legiongames2400 Жыл бұрын
Thank you! :)
@stevedowning3892
@stevedowning3892 9 ай бұрын
Absolutely wonderful tutorial, thanks so much. I am a rank n00b to game dev in general, having downloaded Godot last week. I found it super instructive to type the script along with the video, but to use the Git download to help with fault-finding, when I inevitably made mistakes.
@t3st3d
@t3st3d 10 ай бұрын
thanks! i just switched from unity to godot and this is the most helpfull tutorial i have found so far
@legiongames2400
@legiongames2400 10 ай бұрын
Hey welcome to the engine haha, I'm glad you're enjoying my videos
@ivan-_-8577
@ivan-_-8577 9 күн бұрын
Thank you. A very nice controller and lots of clear and useful code examples!
@m0nste_
@m0nste_ 4 ай бұрын
Thank you so much for this tutorial. I've never really gotten into coding before, so I'm attempting to learn Godot to get into the swing of things. I would love to see another video perhaps diving into crouching implementation as well as crouch sliding! :)
@badunius_code
@badunius_code Жыл бұрын
5:15 or even better, you can rotate your entire body along the Y axis and not just your head. Shadows will give you away if you'll switch to a non symmetrical body.
@legiongames2400
@legiongames2400 Жыл бұрын
Very good point.
@Jacklo-the-catsect
@Jacklo-the-catsect Жыл бұрын
thank you for this, until I rotated the head, the body didn't rotate, and so I looked backwards then walked forwards, I'd be going backwards, but rotating the body fixed that.
@SuitedGhost
@SuitedGhost 10 ай бұрын
​@@Jacklo-the-catsect well thats cause you multiplied the direction by the forward vector of your actual player, not your head (not trying to justify using the head, just sayin)
@cassis2325
@cassis2325 10 ай бұрын
This fix is also better in the way that now your starting rotation of the body doesn't have to be zero in the engine. Now you can rotate the entire body to your hearts content in the engine without it messing up local an worldposition's whilst walking
@mattg6550
@mattg6550 9 ай бұрын
Just for anyone running into trouble here, you will be replacing head.rotate_y(-event.relative.x * SENSITIVITY) with rotate_y(-event.relative.x * SENSITIVITY) to accomplish this, since if we rotate_y (or do any translations or rotations without specifying what we are translating or rotating) we will enact this on the 'scene' that the script is attached to, in this case the root "Player"
@_phloggy_
@_phloggy_ 9 ай бұрын
amazing vid, i've understood pretty much everything you've taught me, thank you!
@sonicfan826
@sonicfan826 8 ай бұрын
This really helped me out, thank you for the tutorial and have a nice day
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you for watching friend! :)
@Paulik76910
@Paulik76910 10 ай бұрын
Thanks for such a detailed tutorial.
@legiongames2400
@legiongames2400 8 ай бұрын
Glad you liked it
@ck88777
@ck88777 12 күн бұрын
great tutorial btw, good pace and straight to the point, just the way a tutorial should be
@LaurenNapier-uk4yk
@LaurenNapier-uk4yk 4 ай бұрын
This was exactly what I needed while I'm learning, thank you! Now for that extra juice I gotta find some way to add a little acceleration and hopefully a faster initial jump speed like source games...
@MerrStudio
@MerrStudio 5 ай бұрын
One thing that's easy to miss cause the effect is subtle but if you have no velocity you don't reset t_bob value so your camera could be shifted ever so slightly from the bob when not moving anymore.
@StrawberryBongo
@StrawberryBongo 10 ай бұрын
thanks so much bro this is such a huge help!
@thricemindblown7883
@thricemindblown7883 8 ай бұрын
My favourite was the headbob function. That "->" should come in handy.
@joefigura6132
@joefigura6132 9 ай бұрын
Great video, succinct and helpful
@tje.o.a5477
@tje.o.a5477 4 ай бұрын
Thank you my dude, this has helped me remake my character controller after I switched to fps!
@legiongames2400
@legiongames2400 3 ай бұрын
Thank you, I'm glad you enjoyed! :)
@TheMikeMassengale
@TheMikeMassengale Ай бұрын
Great stuff keep it up!
@davidmarinho2848
@davidmarinho2848 11 ай бұрын
Great tutorial!!! 👏👏
@monopoly2170
@monopoly2170 11 ай бұрын
Great job! I would recommend using similar lerp functions to add acceleration/deceleration
@captainnelson9833
@captainnelson9833 8 ай бұрын
This is the best tutorial for a FPS character controller. Your code is just too clean for human eyes.
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you friend! :)
@DarkestMirrored
@DarkestMirrored 4 ай бұрын
this seems very useful! the one thing i'd REALLY like to see would be stair handling? none of the player controller tutorials seem to care about being able to use stairs.
@legiongames2400
@legiongames2400 4 ай бұрын
Yeah stairs are a little more difficult tbh, I would love to make a more complete controller one day, but there's a really well-made video that describes the concept in general concepts: kzbin.info/www/bejne/f325hpaVrrtlasksi=rZX2XExOCMyssIs3
@abhatem
@abhatem 10 ай бұрын
Great tutorial, thank you!
@legiongames2400
@legiongames2400 8 ай бұрын
Glad you enjoyed it!
@cyclonebee2205
@cyclonebee2205 10 ай бұрын
Amazing tutorial! Learned a lot about gd script from this.
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you! :)
@LexGear
@LexGear 7 ай бұрын
One thing I noticed is that there was a blurr on the edges of ojects when rotating the camera, this is because the rotation is calculated on the physics layer intbeween frames when it should be calculated on the frame layer _process().
@TheMisterNebo
@TheMisterNebo 10 ай бұрын
Your content is great, you have a good pace (I like the 'faster' pace that you use), and Godot will be all the hype soon enough thanks to Unity's foolery. I subscribed, thank you so much for taking your valuable time to make this content for us. You make learning Godot fun!
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you very much! :)
@Dragon20C
@Dragon20C Жыл бұрын
Looks very cool!
@ProbablyM_S
@ProbablyM_S Жыл бұрын
you can include camera tilt when moving in a direction it looks really cool in part 2 ,can add sound effects for jumping,landing, running, add particles and crouch/sliding hehe ik its too much but would love to see that
@legiongames2400
@legiongames2400 Жыл бұрын
Yeah all of these would be really important for most games!
@ProbablyM_S
@ProbablyM_S Жыл бұрын
@@legiongames2400 is this a taunt or you are serious? 😂
@legiongames2400
@legiongames2400 Жыл бұрын
@@ProbablyM_S LMAO my bad if that sounded sarcastic. No, I'm serious, sound effects are a little tricky here so would be cool to do a vid on that. Plus extra camera movement like a little drop when you land, tilt on strafe, etc would make it even more juicy.
@ProbablyM_S
@ProbablyM_S Жыл бұрын
@@legiongames2400 haha its fine
@px8
@px8 Жыл бұрын
@@legiongames2400 you should do this!! pleaase!
@Harald723
@Harald723 Жыл бұрын
Great toutorial the code works perfectly and i can almost understand it!
@legiongames2400
@legiongames2400 Жыл бұрын
Thank you friend! Hopefully I can do better next time so you understand it all.
@Harald723
@Harald723 Жыл бұрын
@@legiongames2400 well im a beginner so I dont realy know how to code that much!
@johnc7389
@johnc7389 8 ай бұрын
Tremendously helpful.
@arrtemfly
@arrtemfly Жыл бұрын
oh this *was* very helpful and fun. thanks!
@legiongames2400
@legiongames2400 Жыл бұрын
Thank you! :)
@TheValkire
@TheValkire 8 ай бұрын
It would be amazing if you could do crouching and sliding based on current velocity (so you can slide down a slope).I've been trying to wrap my head around it for some days now without success... Great tutorial by the way!
@legiongames2400
@legiongames2400 7 ай бұрын
Cool idea! And thank you for watching! :)
@6lua
@6lua 3 ай бұрын
Thank you so much! You helped me so much. Subscribed on you and liked the video.
@TupyBro
@TupyBro 2 ай бұрын
ооо, неожидал тебя тут увидеть, я делаю свою игру а тут ты в коментах
@6lua
@6lua 2 ай бұрын
@@TupyBro заебал
@DonGeorgesTheThird
@DonGeorgesTheThird 8 ай бұрын
Really great video! Small question though, any chance you can make a follow-up video showing how to handle a controller for motion? I mean, the direction is pretty straight forward as it is a simple mapping of the (in my case) left joystick to the created action (not to mention the jump and sprint buttons) but the camera adjustments are kind of tricky as the game listens to mouse move events (as an input) and for the joystick, it feels like the modification should happen in the _process or _physics_process code rather than from the event itself.
@DonGeorgesTheThird
@DonGeorgesTheThird 8 ай бұрын
Right, after a tiny bit of fiddling, I found it out. Sharing cause it might be useful for someone. The first thing I did was to export the 3 lines handling the rotation in the _unhandled_input function to a dedicated function _handle_rotation taking x, y and sensitivity as parameters. I make sure to pass the final values of x and y (i.e. -event.relative.x). I pass the sensitivity as I want to have a different sensitivity for mouse move and joystick. So I created the input for the right joystick (look_up, look_down, look_left, look_right) and in the _physics_process, I get the values the same way I get them for the movement (Input.get_vector). If the return value is not Vector2.ZERO, I call the _handle_rotation function. Done.
@RandomGuyyy
@RandomGuyyy Жыл бұрын
This video and the following in this zombie fps series are a good introduction to 3D in Godot 4.
@legiongames2400
@legiongames2400 Жыл бұрын
Haha thank you! :)
@RandomGuyyy
@RandomGuyyy Жыл бұрын
@@legiongames2400 proper shooter tutorials with actual animated characters are thin on the ground for Godot so I hope the.algorithm catches wind of it.
@Drivinefire
@Drivinefire 6 ай бұрын
If you update camera bobbing inside the physics process won't the movement look jittery in higher refresh screens? I can't test it myself but maybe it would look smoother in the normal process.
@supposedly2478
@supposedly2478 Ай бұрын
very helpful thank you very much
@Hugo-xr1mg
@Hugo-xr1mg 8 ай бұрын
this was pretty entertaining to watch, although i have a pretty silly question, your Rs are giving a W sound, is that normal? I'm curious
@stagnantgiant4235
@stagnantgiant4235 10 ай бұрын
thank you for this, it helped a lot. I do have a question. I would also like to have the camera movement be controlled by the right stick of a controller. I set up the project inputs for it, but how would use them with your camera movement code to have the player able to use mouse and keyboard OR controller to play
@ColdBlueLight
@ColdBlueLight 6 ай бұрын
thank you sir i was able to create a juiced up first person controller! and mod it to my likeing!
@Redemtor1
@Redemtor1 9 ай бұрын
straight forward video with a snappy sense of humor. love it
@laithalsaj5243
@laithalsaj5243 11 ай бұрын
Hey! I know this is a bit late for a 2 months old video but can you also show me how we can implement the crouch mechanic as well the slide? That would be very helpful from you, Great tutorial by the way!
@ince55ant
@ince55ant 10 ай бұрын
for crouching, just scale down the collision on vertical axis and lower the camera position. also you should do a line trace when uncrouching to make sure your character has the space to stand up for sliding do the same stuff but also stop using the player input for movement/velocity but instead store the forward direction when the slide is first activated and use it for the movement, then decelerate to taste until equal to crouched walkspeed then start using normal crouching behaviour. also make a state machine for movement. i.e. make an enum for movement states like walking/crouched/sliding. then use a switch/match statement to set the velocity in the way each of those states requires
@LexGear
@LexGear 7 ай бұрын
Super helpful.
@user-un2vb8mr6e
@user-un2vb8mr6e Жыл бұрын
Great video, could you make a tutorial that implements head *sway* as well as head bob. Where the head kind of leans/ or rotates side to side when you move side to side similar to in games like Quake, Devil Daggers, Ultrakill, DUSK etc.
@legiongames2400
@legiongames2400 Жыл бұрын
That'd be a cool feature for a potential part two, thank you for the suggestion
@user-un2vb8mr6e
@user-un2vb8mr6e Жыл бұрын
@@legiongames2400 you're tutorials are really great for learning godot. Im currently halfway through the third video. You're second video really helped me understand how to use scenes to create prefabs. Although I've had to use shapes like cylinders, squares and circles as the collision shape for the static bodies because the convex shapes were really bad performance wise at least for me. Anyway keep up the great videos.
@cynkcaj
@cynkcaj 2 ай бұрын
on the off chance you still care about this, just throw "camera.rotation.z = lerp(camera.rotation.z, deg_to_rad(YOUR DESIRED DEGREES) * input_dir[0], delta * YOUR DESIRED RATE OF CHANGE)" in your physics_process
@user-un2vb8mr6e
@user-un2vb8mr6e 2 ай бұрын
@@cynkcaj thanks
@BlueCodingStudio
@BlueCodingStudio 10 ай бұрын
Very useful, I am too lazy to write my own code, so hippity hoppity your code is now my property.
@legiongames2400
@legiongames2400 10 ай бұрын
Wouldn't want it any other way, hope you're enjoying Godot haha
@Andruck
@Andruck 6 ай бұрын
Thanks bro, are the best :D
@Skizzer-is-cool
@Skizzer-is-cool 14 күн бұрын
It took me hours but i did it thanks
@TheRemaindersYT
@TheRemaindersYT 3 ай бұрын
This guy needs more credit!
@ryan_isacow21
@ryan_isacow21 3 ай бұрын
Thanks a little fast but help understand how godots code works
@Thph793
@Thph793 2 ай бұрын
I don't get it. I get like 1-2 fps but when I jump and during the jump/fall and while falling through the void i get perfect 60 fps even when moving the camera, what is this and how can I fix it? I know that my pc isn't that bad so I don't get why I only get good fps while jumping / falling. I already tried disabling the sun fro example but it didn't help 1 bit.
@bonsaipropaganda
@bonsaipropaganda 11 ай бұрын
this is so good
@ryzenslt8943
@ryzenslt8943 Жыл бұрын
Omg thanks so musch all the tutorials Are so old and war
@legiongames2400
@legiongames2400 Жыл бұрын
Thank you for watching!
@mattg6550
@mattg6550 9 ай бұрын
Is there a reason for walk/sprint values being const? If you wanted to add a speed boost or something would it still make sense to structure this way?
@rickymolnar
@rickymolnar 9 ай бұрын
Think of the constant values as a base value that everything else builds off of. If you want to add a speed boost, do something like WALK_SPEED * 2.0 to double their speed. Then, when the boost disappears it reverts back to whatever the base speed is.
@ducky_well
@ducky_well Жыл бұрын
nice , thank you
@nijuatama4362
@nijuatama4362 9 ай бұрын
Just a question for a newbie, is it okay to create the player node and world node in the same scene ?
@jordgoin
@jordgoin Жыл бұрын
Really cool stuff thanks. Out of curiosity how hard would it be to add something to handle stairs?
@legiongames2400
@legiongames2400 Жыл бұрын
Surprisingly complex topic tbh LOL Not too difficult but it is its own thing, check out this video kzbin.info/www/bejne/f325hpaVrrtlask
@JayTube7580
@JayTube7580 Жыл бұрын
I thought you just made an invisible ramp so they didn't get stuck on the stairs.
@mxrgan_
@mxrgan_ Жыл бұрын
Hey, I was just wondering, how can I put in a camera tilt like in Quake or Half-Life that happens when you strafe? I tried implementing some methods but all of them cause the camera to rotate in wierd ways in game.
@legiongames2400
@legiongames2400 Жыл бұрын
You could maybe try doing it with an animation player if it's not working out through code.
@CSS-Dist00pia
@CSS-Dist00pia 11 ай бұрын
thx my dude =)
@MonkeyMan-idk601
@MonkeyMan-idk601 5 ай бұрын
I have a problem with the camera I did all the code and I put it where I wanted it, but it keeps going to the bottom of the capsule
@GorgeousPuree
@GorgeousPuree 9 ай бұрын
4:48 That's weird, but when I use clamp, it seems to work like in the video if I move mouse slowly. If I pull the mouse up/down sharply, z index of the camera goes crazy. It rotates around itself.
@GorgeousPuree
@GorgeousPuree 9 ай бұрын
The reason for that is I manipulated Camera's coordinates. I should've created a Node3D object as a parent of camera (basically what it's shown in this tutorial). But I thought there's no difference. If you work with Camera's rotation, you may face Gimbal lock, as I was told.
@gregorymirabella1423
@gregorymirabella1423 26 күн бұрын
idk why but the head bobbing is bugged for me. i copied it exactly but it causes the camera to fall to the model's feet. i just ditched it entirely but i have no idea what was going on with it.
@tommysimonnes1045
@tommysimonnes1045 Ай бұрын
Thanks!
@Jacklo-the-catsect
@Jacklo-the-catsect Жыл бұрын
this helped thank you, although I would suggest 0.007 as the sensitivity, as it's much slower, but still fast enough, it also doesn't make you feel like you're on a rollercoaster.
@legiongames2400
@legiongames2400 Жыл бұрын
Yeah people tell me my mouse sensitivity is too high all the time tbh. :D
@SuitedGhost
@SuitedGhost 7 ай бұрын
i just multiplied it by the process delta time ._.
@brooke6472
@brooke6472 4 ай бұрын
Do you know how I could add crouching, and make it lower the position of the camera? I tried, doing what I thought could possibly work, but it didn't.
@kevinrunnion5790
@kevinrunnion5790 11 ай бұрын
How are you making the camera smaller to fit on the capsule
@gogglesnakdev-nt3yw
@gogglesnakdev-nt3yw Ай бұрын
good tut! but my camera is at the players feet since i added the camera bobbing any thips?
@lionlight9514
@lionlight9514 Жыл бұрын
Hi, great video! I absolutely loved the camera bobbing. I was wondering on how I can add enemies? I'm new to Godot!
@legiongames2400
@legiongames2400 Жыл бұрын
Hey thank you for watching! I'm currently working on a level design video & then a video on that exact topic after that. To point you in the right direction for now look into creating enemies with CharacterBody3D just like the player and then adding a NavigationAgent3D so they can navigate your map and chase the player around.
@lionlight9514
@lionlight9514 Жыл бұрын
​@@legiongames2400 Thanks, but why not a rigidbody?
@legiongames2400
@legiongames2400 Жыл бұрын
@@lionlight9514 Rigidbodies are not really intended for use with characters you're moving through code. They're more for props or puzzle objects you're pushing and moving around with your character. Rigidbodies are fully physics simulated and instead of the useful move_and_slide function you have to apply directional forces to move them around so they're extremely annoying to use for anything but that.
@lionlight9514
@lionlight9514 Жыл бұрын
@@legiongames2400 Ah, makes sense. Thanks!
@georgesal-habre103
@georgesal-habre103 10 күн бұрын
When i have added the bob, the camera was on the floor, i have added "1.8" on "pos.y" to correct this issue. Not sure why the camera was on the floor ...
@ST3FF3
@ST3FF3 3 ай бұрын
I added a dash ability into this template but I have a problem with the inertia. Dashing creates a Vector3 that gradually decreases to zero. The dash vector is then added to the velocity vector and this works well on when on the floor (since I haven't added inertia when on the floor). However when dashing in the air the player velocity gets super fast. Any tips on how to fix this? Here's how I tried to make it work: velocity.x = lerp(velocity.x, direction.x * SPEED, delta * 2.0) + dash_vel.x EDIT: I got rid of the dash vector and just added the dash amout to the velocity and added an if statement for lerping the velocity if it's higher than the const SPEED and now it works
@oleksandr-petrovych
@oleksandr-petrovych Жыл бұрын
In your project, the physics/common/physics_ticks_per_second is set to 144, and if you reduce it to 60, the objects in the scene begin to shake. How to fix it?
@legiongames2400
@legiongames2400 Жыл бұрын
Short answer is don't change it to 60 per second. I changed it to 144 because I had that jitter since my monitor has a higher refresh rate. It sounds like you have a 144 hz monitor too if you're getting a jitter at 60 ticks per second. Read this for more info: docs.godotengine.org/en/stable/tutorials/rendering/jitter_stutter.html
@InHUM44n
@InHUM44n 9 ай бұрын
For anyone wanting to untie player movement from physics tickrate: For me moving move_and_slide() to _process(delta) instead of _physics_process(delta) fixed the "laggy" 60fps camera translation movement. Now my physics framerate is 30 to save performance on the CPU and it still feels good :)
@kabebu_
@kabebu_ 8 ай бұрын
I've been searching for the cause of those "lag spikes" for 2 days... Thank you :')
@annoyingkittycat6449
@annoyingkittycat6449 6 ай бұрын
I've heard if a big lag spike hits it can completely mess up your physics engine if you do this from another youtuber, but I'm not sure if its true
@airtight-gamingnews3910
@airtight-gamingnews3910 3 ай бұрын
Ok so I'm having an issue where if I walk diagonally and stop now the character slides a tiny bit to the left or right depending on if I was walking backwards or forwards, its a small thing but I don't know how to fix it. Any suggestions?
@dithercrisp
@dithercrisp 7 ай бұрын
This was a great tutorial! The pacing was great and your instructions were easy to understand. One problem that i'm having though is that when i jump my characters trajectory starts to curve to the left when i jump. How could i fix this? It also seems like when i press movement keys my character starts walking in one direction infinitely. EDIT: Nevermind i'm dumb i wrote velocity.y when i should've written velocity.z
@legiongames2400
@legiongames2400 7 ай бұрын
Thank you for your kind words!
@dt295
@dt295 2 ай бұрын
I don't know if I did something wrong or what, but when i did the FOV part from the video, I felt something was off when trying it in the game. When jumping, the script seems to take the speed of the jump momentum and that causes the fov to change, making a strange wave of the fov, going up, down and up, which I didn't like at all. So trying things for like an hour or 2 (with the absolutely little I know about Godot, this is the first video I've seen of Godot, which is very good) I changed this part of the script: var velocity_clamped = clamp(velocity.length() - velocity.y, 0.5, SPRINT_SPEED * 2) It seems that by subtracting velocity.z from velocity.length(), the wave disappears and not only that, but now the fall feels much more powerful the higher you are (but it seems to have a limit), it's quite good. I hope it helps someone, and if I'm wrong about anything, please let me know. I want to thank the creator of this video, because with such a short video, and even me speaking another language natively, it gave me the possibility to try to do things on my own in the code, despite it being the first time I touched it , thank you so much.
@user-he1hs6qk3h
@user-he1hs6qk3h 9 ай бұрын
That’s cool. How do you change it to third person perspective?
@samuelhugo3387
@samuelhugo3387 5 ай бұрын
great tutorial! my character moves well now, I just wanted to ask, is their a way to tune the headbob so that you can match it up with footstep sound? I have added footstep sounds to the game but the headbob doens't happen at the same speed and it looks unnatural, I need a way to increase/decrease the freq of the sin wave
@georgesal-habre103
@georgesal-habre103 10 күн бұрын
change "BOB_FREQ" value
@samuelhugo3387
@samuelhugo3387 7 күн бұрын
@@georgesal-habre103 honestly this is so long ago I can't rember but i probably tried that I mean its probably the very first thing I tried I don't know how but I do think I got it working in the end
@mattyalan6010
@mattyalan6010 2 күн бұрын
The first 1.30 seconds of this video is a bloody speed run.
@watercat1248
@watercat1248 10 ай бұрын
i have crital question how to make a public veritable in Godot what i mean be that is to meke var to show on the inspector this very important for my project because some code like the player speed it may be different for some off the charters and i dont wand to write mulpe code with only different to be the speed number the other reason i wand to know how to do that is in the order to twining the player such
@ck88777
@ck88777 12 күн бұрын
isnt it bad that t_bob increments forever? wont it run into some precision error eventually (theoretically)? maybe it doesnt happen in practice
@gli7ch240
@gli7ch240 6 ай бұрын
How do i make this for mobile / toich screen i got the joustick to work woth movement but when j play it moves but as soon as i toich the screen with my finger it dont rotate andnfreezes. Plz help
@Charles.the.grumpy.gremlin
@Charles.the.grumpy.gremlin 4 ай бұрын
Can you help ive copied one for one on the mouse stuff but it just doesnt work pls respond
@keagansettle7962
@keagansettle7962 9 ай бұрын
Anyone else's crashing from the the unhandled_input event? I have copied the code verbatim and even tried the full body rotation mentioned in the comments and it doesn't seem to work for me either
@legiongames2400
@legiongames2400 8 ай бұрын
What's the error you're getting?
@mr.draven018
@mr.draven018 4 ай бұрын
Hello, I don't know if I'm the only one with this problem but it happens that when I try to jump diagonally, that is, by pressing two movement keys at the same time, it doesn't jump except when I press up and right, it jumps there, it's strange.
@troutwithfingers
@troutwithfingers 6 ай бұрын
hey, when i let go of sprint it jumps back down to the base fov instead of interpolating back so im trying to add that. how would i go about doing that? i added a line before the camera fov lerp to do it upon pressing the sprint buton, but i cant figure out how to make it lerp back down to the base fov when i release the sprint button EDIT: cant figure out how to do it how i described above but i found if i put the camera lerp under an if SPRINT_SPEED statement it changes your fov depending on the characters velocity. im not experienced with coding at all so i dont know if this is a dumb way to do it but it looks and feels good for the parkour type of game im going for
@legiongames2400
@legiongames2400 6 ай бұрын
Hey if you're copying the code the FOV shouldn't be jumping around. Could you double check that you have a target FOV like I do and that you're interpolating the camera FOV towards it? Another reason could be that you're interpolating but with a very high delta so it looks like it's jumping. Would you mind copy pasting your FOV code in here?
@TheRamblingOne
@TheRamblingOne 5 ай бұрын
4:48 the camera ends up spinning on the z axis, i think ive done everything right. Saw someone with a similar problem in the comments but theirs was because of the way they did their node, mine are the same as yours tho.
@rapgen5805
@rapgen5805 8 ай бұрын
thank you!
@legiongames2400
@legiongames2400 8 ай бұрын
Thank you for watching! :)
@Extner4
@Extner4 Жыл бұрын
the mouse sensitivity changes depending on the window size. Can you prevent this by dividing it by the screen size?
@legiongames2400
@legiongames2400 Жыл бұрын
Wasn't aware of that. Yeah, that wouldn't be difficult to do, you figure out what you want the baseline size of the screen for your sensitivity to be. Then you can use get_viewport().size and divide your baseline x and y sizes by it to get the number you want to multiply your inputs by.
@neolinkgames
@neolinkgames 5 ай бұрын
So I did everything and it was working fine and then I tried to do a prefab out of the player node and now @onready var head = $Head @onready var camera = $Head/Camera3D gives me : @_ready(): Node not found: "Head" (relative to "/root/player") etc I tried to go back and it still gives me this error. I'm kinde of confused.
@lead1320
@lead1320 Жыл бұрын
Thank you for this tutorial! I am planning on making an infinite tower climber with this. For some reason, when I pressed the w key I went backwards, and the s key made me go forward. I switched which one was in the input for up and down, and that seemed to fix it. Do you know why it may have happened?
@legiongames2400
@legiongames2400 Жыл бұрын
Thank you friend! :) It sounds like the camera might be facing the wrong way?
@lead1320
@lead1320 Жыл бұрын
@@legiongames2400 Thanks, that seemed to fix it. I am now subscribed.
@x2-gamerz23
@x2-gamerz23 Ай бұрын
if Input.is_action_pressed("zoom"): var target_fov = -10.0 camera.fov = lerp(camera.fov, target_fov, delta * 8.0) code for zoom function. (note: add a zoom input key in the project settings)
@MUIzViper
@MUIzViper 6 ай бұрын
Whenever i was adding the head bob it stoped letting my look around after i got the code at 6:56 ?
Design 3D Game Levels From Scratch - Godot 4 Tutorial
11:04
LegionGames
Рет қаралды 116 М.
The Best New Features Coming in Godot 4.3
11:40
Gamefromscratch
Рет қаралды 49 М.
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 22 МЛН
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 10 МЛН
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 4,7 МЛН
3 Devs Make An FPS - Godot vs Unity vs Unreal || GameDev Battles
12:39
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 490 М.
I Created The PERFECT Movement In Unity...
11:00
TheCodingPencil
Рет қаралды 13 М.
Complete 3D Shooting Mechanics - Godot 4 FPS Tutorial
12:14
LegionGames
Рет қаралды 94 М.
I learned game development for 6 months...
11:42
Soup Plays
Рет қаралды 50 М.
4 Months of Game Programming With My Own Engine
21:30
jdh
Рет қаралды 423 М.
Immersive Sim in Godot 4: COGITO - Overview
8:22
Philip D
Рет қаралды 35 М.
When Your Game Is Bad But Your Optimisation Is Genius
8:52
Vercidium
Рет қаралды 1,4 МЛН
Best father #shorts by Secret Vlog
00:18
Secret Vlog
Рет қаралды 22 МЛН