For anyone struggling with the character not moving when pressing WASD, in the project settings you have to actually bind the keys to the commands using the "+" to the right of the action. After that it should work great!
yea there's a lot of small useful bits that got cut out, i thought maybe i just missed them, like the CameraController accepting data type "Camera3D", instead of Node3D
👉🏼 PROJECT SOURCE FILES ►► github.com/StayAtHomeDev-Git/FPS-Godot-Basic-Setup 👉🏼 BECOME A SPONSOR ►► www.patreon.com/StayAtHomeDev_ *Had to switch to Patreon from GitHub Sponsors
For newbies and beginners to be able to follow along it would have been nice if you showed how to add the environment and light to the scene, for beginners it might not be so easy to find. This series is promising! Looking forward to the next episodes! Cheers!
Will definitely be covered at some point! The WorldEnvironment node is kind of a beast of a node. Plan is to keep videos very focused so there isn't "information overload". It definitely deserves its own video.
I have watched many tutorials and most of them just code without explaining hte logic, or use. You got to be the most clear and beginner friendly tutorial out there ! :D
Just the series I was looking for. I'd been doing intro tutorials for a while and I find the pace and content of this to be more advanced and quick. I wouldn't be able to hang if I hadn't been doing tutorials for 3 months and I appreciate this sort of forcing me to branch out and keep up. Thank you thank you thank you!
I have immense respect for your decision to open-source this fundamental project! There could be no better introduction to the Godot community, nor a better welcome for devs moving beyond closed-source ecosystems. It also pairs well with your paying ventures to help support the channel. Kudos and keep up the good work!
For "@export var CAMERA_CONTROLLER : Camera3D" I used Node3D instead of Camera3D, I did this so that I can select the CameraController node (which it looks like you actually have selected in this video, which isn't possible while following your directions, at least in the newest version of Godot (4.2.1)). I did this so that the vertical movement of the camera can have a rotation point separate from the camera. Many games have the camera tilt from a point below it, like as if it's the character's neck or waist that it's rotating from. I don't know if this will conflict with things you do down the line but that's what I did to get it how I wanted.
I did the same as you lol He never points it out in the video, but after explaining to use Camera3D, you can see he changed it to Node3D just before he scrolls away
I Can't Believe This As A Kid Who Codes This Is The *Only Godot Tutorial That Works,* Like Theres No Other Tutorial Like This Keep Up The Good Work ❤❤❤😊😊😊
Love this! In a (much?) later episode, I'd love to see how you tackle the world environment node, lighting, and graphical settings. Those looking to create an FPS typically want it to be a little higher up on the graphical scale (though, certainly not all), and some of the hardest resources to find are how to make 3D Godot look good because the settings out of the box simply aren't set for higher fidelity - which leads many to think 3D graphics in Godot are bad - when in fact you just have to set the settings accordingly and its a bit more manual setup.
Okay so I'm following the tutorial but it doesn't work at the camera, I keep getting invalid get index 'transform' on base nil. Idk how to fix pls help
Was stuck here too. Someone answered it a few comments ago - go to the Inspector of your CharacterBody3D and where it says Camera Controller, select Camera3D
My cam era is stuck in a single orientation even after trying this. Anyone got a fix? EDIT: I had indented my code wrong so that the _update_camera function only updated when the controller was not floored
Just throw it out there but keeping your code on screen for an extra sec is very helpful for us following along. Great video though I like the series so far
Thank you for making such an incredible tutorial series. Your pacing, and the amount of information in each video are perfectly succinct. Thank you, please keep it up! Waiting every day for the next video to be visible! 🙂
in your script you have @export var CAMERA_CONTROLER:Camera3D and you said that it should Camera3D and than it it silently change to Node3d which is correct type. This is not my first FPS Controler i am doing so it is easy for me to spot this, but for begginers it can be quite confusing.
Please add explanation on those 2 line CAMERA_CONTROLLER.transform.basis = Basis.from_euler(_camera_rotation) global_transform.basis = Basis.from_euler(_player_rotation) why you decide to manipulate the Basis and not the rotation
It's always amazing to dive into something new. Nobody can take Godot from us - so learning it is no bet on some "benevolent" company. Thank you for the video! 👍
I just started working with Godot and it's been great, I'm glad to see more tutorial videos with the engine. I haven't found a tutorial for how to filter over a 3D camera, like what those PS1-style horror games do. I've only found old videos for 2D games, It would be great if there was a tutorial.
@@stayathomedev Probably, honestly I don't really know what it is or is called. I just started with CS and deving so I'm pretty new too it, but like the closest thing I saw was some dude using a shader to pixelize a 2D sprite.
Going to try to cover as much as possible as it progresses. Will try to branch out realistically to new topics as we create a solid FPS controller than you can also customize to your needs.
Great vid although I wish some concepts of how the code works were more thoroughly explained (euler basis, transform, y axis is up and z axis is through the screen, so player rotation is rotation about the y-axis, and camera tilt is rotation about the x-axis, etc. )
Great tutorial! I have a question though, you have set the type hint of the CAMERA_CONTROLLER variable to Camera3D, yet you reference the CameraController node which is a Node3D, I can't replicate this, nor does it make sense to me. Thanks for the video nevertheless!
Ah! Yes, I must have had the footage wrong. Node3D works fine, so you can reference either. But I will reference the parent node and not the actual camera node. So not Camera3D
Thanks for this tutorial, this is fantastic! Something I did notice with this though is that the mouse sensitivity winds up being tied directly to the frame rate. Because the `_unhandled_input()` method runs every frame, it store the mouse movement based on how far it's moved since the last frame. With a higher frame rate, this directly results in the mouse movement variables having a smaller value, which means that when the `_physics_process()` runs it will move the camera/player less than it would with a lower frame rate. I was able to verify this by coding in a max frame rate toggle that would alternate between running at 60fps and 360fps. I think you can avoid this frame rate dependency by moving the camera movement logic into the `_unhandled_input()` method, but I am new enough to Godot that I'm not certain if there would be any downsides to doing it that way. Please correct me if I've missed something, I would love the opportunity to learn!
I added two other quality of life updates for debugging. A button to switch the mouse_mode from captured to visible and back and a label displaying the frames per second. Here's the code for the mouse switch (obviously you have to add another button to your button mapping): if event.is_action_pressed("switch_mouse_mode"): if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED: Input.mouse_mode = Input.MOUSE_MODE_VISIBLE else: Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
I think i know what to do now, in 3d you go to characterbody3d and in the inspector you should see Camera controller somewhere at the top, click it and select your node you use as the neck
This was and instant like and subscribe for me. Your explanations are beautiful, adds so much to the video; i only had to watch it once instead of 3-4 times. On top of open source for the whole tutorial project.
Non of this worked for me can you please do an updated version for the latest version of godot 4 I have tryed this almost 7 time every step and even tryed my own methods but non of them worked
Hey, as someone coming from unity, these tutorials are super valuable right now so thank you very much ! Also I would like to ask if you are going to implement stair stepping functionality ? I have problems with finding decent solution and a lot of people are saying "just use slope" which I dont really consider as good solution. I really dont want to setup a slope for every little bump on the map.. that would be very annoying to do. Its really surprising to me, that there is no standardized solution for this in Godot since Unity has that in their CharacterController by default for ages.
There's a neat solution for stair stepping in Godot that, in theory sounded preposterous to me for a long time,... until I noticed Thief uses it, and that in practice it actually never bothered me that much (only a tiny bit): the solution is using a SeparationRayShape3D (in a ShapeCast3D node) under an elevated capsule (Thief used two vertical spheres). The nice thing about it is that the ray shape will handle stairs naturally on its own and push the player up the steps, or make it stick down the steps. You may still want to interpolate the camera movement, though. The length of the separation ray defines the max height of climbable steps. The downsides of this method are kind of obvious, but may not matter at all depending on the game. - You will step down into tiny gaps. You don't get stuck, but if the floor has too many gaps it can be annoying (though the camera interpolation can reduce this). - falling off ledges requires falling off twice, once for the ray and another for the player shape. It kinda feels like you fall on your butt before actually falling off the ledge. - you will have trouble walking or landing on very small platforms, thin walls, and things of that nature. One of the upsides, is that that you don't have to correct your maps to remove collisions from wall baseboards and that sort of stuff, because with this method players can't step onto that kind of thing at all. I'm considering using this method for some horror games, that don't really require any ground precision, for example.
I had an issue with the clamp where it did not stop spinning on the x axis. The z axis was already being reset so the camera stayed upright but it would flip backwards if I looked up! watched the camera segment probably over 12 times so I'm confident I copied it right, but I eventually found that it WOULD clamp... but not after 90 degrees, but probably closer to 90 radians, meaning it would stop after a lot of spinning. Fixed it by clamping it by -2 and 2 instead.
Nice tutorial. I solved most of these before seeing it, but I didn't know about captured mouse or that reflection probe node. I should add that to my game. I'm working on a movement shooter, mostly inspired by DOOM. Currently I just got half-pipes working properly, but if I run into the intersection of a vertical wall and flat floor I loose all of my speed instantly. I think it has something to do with how I bodged together conservation of momentum working with slopes. Also, I spent ages figuring out how to get friction to vary depending on the player's angle relative to their movement angle, only to find in playtests that it's not particularly fun.
Dude! Can you show us how to map these controls to a controller? The right stick to rotate and look around, in particular? All the other buttons are simple and straightforward, but that camera is a little tricky. I learned the mouse controls on Zenva already but I'm stuck on controller mapping
We'll go over controller setup for sure. The goal is to get a really solid controller setup (moving, sprinting, jumping, animations) then add controller option.
I'm trying to follow along with this awesome tutorial but in C# and I'm running into a problem. If you could help that would be amazing. At 11:53 in line 46 you do: global_transform.basis = Basis.from_euler(_player_rotation) In C# that translates to: GlobalTransform.Basis = Basis.FromEuler(_playerRotation); However it says "Cannot modify the return value of 'Node3D.GlobalTransform' because it is not a variable." Would you have any idea about this?
Just downloaded the project from github because for some reason the character won't move after following what you did and it still did not work. Inputs are correct and I have added the keybinds on both my project and the github project, I cannot see what could be going wrong
One question... after we fix camera rotation so the player rotates with it, the scene always starts with player facing the negative Z axis. Rotating the player body doesn't solve it, and I've noticed it happens in your tutorial as well. I'm using Godot 4.3. How can this be fixed? Rotating the CharacterBody on the level messes up the controls because it rotates only the camera, not the whole body.
Putting _update_camera(delta) in the _physics_update() function causes my camera to be very jittery. I assume this is because the physics_update is capped to 60. Did you not have this issue too? @StayAtHomeDev?
Something that I noticed about this particular implementation of mouse look, is that when you start the game the player is always looking in the same direction, regardless of which direction the player scene is facing in the level (IE, PlayerCharacter has been placed in the scene and was rotated 90 degrees). How exactly would this be fixed? It would be a very real problem for every player of a game (singleplayer OR multiplayer) to be looking Exactly North every time they load the game.
Very well explained! Only problem is that the script, copied and pasted straight from the repo, doesn't pick up any mouse movement. Printing rotation and tilt input leads to a sea of (0,0) vectors. EDIT: Figured it out, I had a ColorRect gobbling up the mouse input. Make sure its mouse behavior isn't set to Stop in the inspector.
Good edits and good vibes! And I really enjoyed it But I feel having the goal of making it simple by not over-explaining, It made me feel a lot of it was just "magic codes" that I just had to copy and paste and none of it has any meaning It makes me be scared of coding I wished you explained every line of code a lot more
Im curious about the light probes. I dont have a ton of experience with light probes but in unity and unreal, I thought they were suppose to be static and it helped handle light data as the camera passed through them. Putting it on the camera sounds like potentially unneeded stress since the camera is needed for movement and the probes would be constantly moving and rotating. I wanted to ask about this since my major areas of noobness are light and shaders. Maybe godot functions differently when it comes to probes.
Dios mio yo hablo español y asi entiendo a que te refieres en el tutorial en verdad este es el mejor curso explicas todo a detalle dios tengo un proyecto batleroyal en godot que estoy comenzando aser nesesitaba un tutirial como este muchisimas gracias bro en serio gracias
Nice! This tutorial format is really good, looks super polished, and definitely feels inspired by Brackeys :) I hope this becomes a regular thing! I'm curious why you're multiplying the mouse input by delta? Shouldn't mouse movement be absolute? I think what you want is a much lower sensitivity instead (normal sensitivity numbers are based on degrees not radians, which is why the math looks different from other engines). If you use delta, then at low frame rates your sensitivity will go way up.
Something to be looked at in another video I think to have time to explain the issue. And thanks! Hoping the format works well. There was some inspiration :P
If anybody has a issue with running the code and you get error invalid get index 'transform' on base nil on the line CAMERA_CONTROLLER.transform.basis = Basis.from_euler(_camera_rotation). try moving ( litteraly click and drag the 3d camera) back onto your Character body 3D. Worked for me! Just forget the extra node he made you create at the start
Wonderful tutorial, thank you for taking the time to make this! One question, I'm not sure why but every time I move my mouse the whole scene flickers... I think it's the reflection node we added. It might be a Godot 4.3 version problem... any help?
Yo this is a sick video so far but the func _unhandled_input(event) function on line 18 has multiple errors and says "expected expression after "==" operator" how do i fix it
If it's constant then it can't be changed once the game starts. Maybe you want all those values to be part of the game settings menu, then it's better to leave it as var and not as const.
You could if you really didn't want those to be adjusted...as the other commenter said...I think it becomes a customization issue and also not creating variable walls early on. May encounter a feature where the tilt needs to be narrowed or disabled for example.
So, I've just discovered this channel through Thomas Brush, he out a post about your channel. Im thinking about coming to Godot. Will this cover setting up enemies as well as the player character? You may have already done this but i have juat started watching.
For some reason when i use the reflection probe and hdri the reflection light flickers a lot. I dont know why this is happening so im just going to use the procedural sky.
also, it is a bad practice as it lower's fps. instead make the reflection probe static to only the places where it is required detached from the player.
hi! love the series, one question - when I use the grid shader for multiple objects as the material, if I change the albedo color of one, it does it for all of them. How can I separate this? Thanks!
Hi, would it be possible to get the project using compatability renderer instead of forward+? My laptop doesn't support Vulkan unfortunately so I can't edit the project.
Will you do melee weapons and bows? I'm wondering if this would give me a good base for Kings Field like game. I'd have to figure out spells too... I'd guess lobbing a grenade would be quite similar to casting a spell? Why do you use _ in front of variables?
when i turn it on it just doesn't work here's my code extends CharacterBody3D const SPEED = 5.0 const JUMP_VELOCITY = 4.5 @export var tilt_lower_limit := deg_to_rad(-90.0) @export var tilt_upper_limit := deg_to_rad(-90.0) @export var camera_controller : Camera3D var mouse_input : bool = false var mouse_rotation : Vector3 var rotation_input : float var tilt_input : float # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") func _input(event): if event.is_action_pressed("exit"): get_tree().quit() func _update_camera(delta): mouse_rotation.x += tilt_input * delta mouse_rotation.x = clamp(mouse_rotation.x, tilt_lower_limit, tilt_upper_limit) mouse_rotation.y += rotation_input * delta
func _unhandled_input(event): mouse_input = event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED if mouse_input: rotation_input = -event.relative.x tilt_input = -event.relative.y print(Vector2(rotation_input,tilt_input)) func _ready(): Input.mouse_mode = Input.MOUSE_MODE_CAPTURED func _physics_process(delta): # Add the gravity. if not is_on_floor(): velocity.y -= gravity * delta _update_camera(delta) # Handle jump. if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var input_dir = Input.get_vector("left", "right", "up", "down") var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() if direction: velocity.x = direction.x * SPEED velocity.z = direction.z * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) velocity.z = move_toward(velocity.z, 0, SPEED) move_and_slide() idk what it is please help me
It may be too late now, but you need to call your camera node in your export variable. @onready var CAMERA_CONTROLLER : Camera3D = $CameraController/Camera3D #or whatever you named your camera nodes)
I don't get why we set _rotation_input to relative x mouse movement and _tilt_input to relative y movement, but then in _update_camera(delta) we set _mouse_rotation.x to _tilt_input and _mouse_rotation.y to _rotation_input. Is this not the opposite of what it should be? I mean, it works, but why?
Hey there! I am just getting into game-making, I'm wondering whether it's better to enroll in a programming course or dive into projects with the Godot game engine. What do you think is the way to go?
Hi, I noticed a bug in the deceleration code. It appears that one axis can stop before the other. This can create an odd "sliding sideways" movement at certain angles as one axis will be completely stopped, but the other will still be decelerating. I don't have a fix for it, but just something I noticed in my own project.
I have a problem with the _update_camera(delta) line in physics process function. i have an error code saying nvalid get index transform on base nill. i made sure everything was typed correctly. please help
Hey loved the tutorial ! Just wanted to ask but am i the only one that has a weirdly low fps end result ? When trying with other tutorials it doesn't. It seems to happen during the camera script set up, if anyone knows if it's normal i'm taking it
Cant wait to work through this!
Wow! Awesome! Thanks!
20 bucks?!!!!????
@@TRFWINGS yeah, same.
20 BUCKS!?!?!|?
This is such a well-made tutorial. Thanks for sharing this and for all the hard work you put into it.
Hey!! Same to you and your tutorials! Thanks I really appreciate that, having fun in all honesty.
For anyone struggling with the character not moving when pressing WASD, in the project settings you have to actually bind the keys to the commands using the "+" to the right of the action.
After that it should work great!
Thanks for pointing that out. Oversight on my part!
Thank you, I redid my project three times trying to get it to work.. lol
So Many thanks,
yea there's a lot of small useful bits that got cut out, i thought maybe i just missed them, like the CameraController accepting data type "Camera3D", instead of Node3D
👉🏼 PROJECT SOURCE FILES ►► github.com/StayAtHomeDev-Git/FPS-Godot-Basic-Setup
👉🏼 BECOME A SPONSOR ►► www.patreon.com/StayAtHomeDev_
*Had to switch to Patreon from GitHub Sponsors
For newbies and beginners to be able to follow along it would have been nice if you showed how to add the environment and light to the scene, for beginners it might not be so easy to find. This series is promising! Looking forward to the next episodes! Cheers!
Will definitely be covered at some point! The WorldEnvironment node is kind of a beast of a node. Plan is to keep videos very focused so there isn't "information overload". It definitely deserves its own video.
@@stayathomedev Will wait for this one!
Yeah, I would love to know how to make a foggy night sky box with a big moon.@@stayathomedev
LegionGames has a video exactly on that, if your aim is to make a "creepy" map. Not sure how up to date it is tho @@MidnightHorrors666
How would you make that cameras work with user right stick on a PS4 controller? That's the only thing I'm missing.
I have watched many tutorials and most of them just code without explaining hte logic, or use. You got to be the most clear and beginner friendly tutorial out there ! :D
Just the series I was looking for. I'd been doing intro tutorials for a while and I find the pace and content of this to be more advanced and quick. I wouldn't be able to hang if I hadn't been doing tutorials for 3 months and I appreciate this sort of forcing me to branch out and keep up. Thank you thank you thank you!
I have immense respect for your decision to open-source this fundamental project! There could be no better introduction to the Godot community, nor a better welcome for devs moving beyond closed-source ecosystems. It also pairs well with your paying ventures to help support the channel. Kudos and keep up the good work!
Thanks, I really appreciate that! Yes, patrons get full access to everything to use in their own projects.
Thanks!
For "@export var CAMERA_CONTROLLER : Camera3D" I used Node3D instead of Camera3D, I did this so that I can select the CameraController node (which it looks like you actually have selected in this video, which isn't possible while following your directions, at least in the newest version of Godot (4.2.1)). I did this so that the vertical movement of the camera can have a rotation point separate from the camera. Many games have the camera tilt from a point below it, like as if it's the character's neck or waist that it's rotating from. I don't know if this will conflict with things you do down the line but that's what I did to get it how I wanted.
I did the same as you lol
He never points it out in the video, but after explaining to use Camera3D, you can see he changed it to Node3D just before he scrolls away
I had the same problem. Thanks for the comment!
Same for 4.3.x
I get CAMERA_CONTROLLER = null even when changing Camera3D to Node3D
yes ! Now this is what I am talking about. Finally, a tutorial video by SAH !
I Can't Believe This As A Kid Who Codes This Is The *Only Godot Tutorial That Works,* Like Theres No Other Tutorial Like This Keep Up The Good Work ❤❤❤😊😊😊
Love this! In a (much?) later episode, I'd love to see how you tackle the world environment node, lighting, and graphical settings. Those looking to create an FPS typically want it to be a little higher up on the graphical scale (though, certainly not all), and some of the hardest resources to find are how to make 3D Godot look good because the settings out of the box simply aren't set for higher fidelity - which leads many to think 3D graphics in Godot are bad - when in fact you just have to set the settings accordingly and its a bit more manual setup.
Absolutely! There is a lot of power there, it just doesn't come out of the box like Unreal.
Damn, that's a cool fps controller, good job.
Thanks! Just the beginning. Lots of features and mechanics planned, and will document everything with the tutorial series.
Thank you for this tutorial series, as a beginner unity developer who was 6 months in development I lost alot of faith in unity.
You're very welcome!
Okay so I'm following the tutorial but it doesn't work at the camera, I keep getting invalid get index 'transform' on base nil. Idk how to fix pls help
Was stuck here too. Someone answered it a few comments ago - go to the Inspector of your CharacterBody3D and where it says Camera Controller, select Camera3D
@@xephyr1171 just fixed it, tysm
@@xephyr1171 apreciate you!
My cam era is stuck in a single orientation even after trying this. Anyone got a fix?
EDIT: I had indented my code wrong so that the _update_camera function only updated when the controller was not floored
@@ThatGauss Where did you do it please help me
this is a very well made video, just watching it makes u feel good due to its really nice editing, thank u lots
Just throw it out there but keeping your code on screen for an extra sec is very helpful for us following along. Great video though I like the series so far
Thanks for the tip!
never seen a tutorial so well organized
I love how you mentioned modern FPS then showed Half-life 2 ❤
You did something really great here! Thank you.
dude just breezes over stuff because he gets it and doesnt put himself in the shoes of someone seeing it for the first time
Wake up babe, new pronunciation of Godot just dropped
Thanks for this sir 🎉
This is fantastically helpful.
Thanks for all the information.
Great stuff! just started to learn Godot and will probably hop back in once ill be abit more familiar with the basics for a follow-up of this!
This is outstanding! Love your work sir!
Thank you for making such an incredible tutorial series. Your pacing, and the amount of information in each video are perfectly succinct. Thank you, please keep it up! Waiting every day for the next video to be visible! 🙂
Did he mention that you have to select the Camera3D in the exported part of the inspector
in your script you have @export var CAMERA_CONTROLER:Camera3D and you said that it should Camera3D and than it it silently change to Node3d which is correct type. This is not my first FPS Controler i am doing so it is easy for me to spot this, but for begginers it can be quite confusing.
Can you say why mouse isn't track?
Thank you in advance.
sorry, but without code or error message at leats is imposible to tell. @@apofex
Thanks a lot for this!!!
ah yes, my favorite FPS controller feature, the Real-Time Reflection probes BEFORE capturing the mouse
Thanks dude, actually really helped.
Please add explanation on those 2 line
CAMERA_CONTROLLER.transform.basis = Basis.from_euler(_camera_rotation)
global_transform.basis = Basis.from_euler(_player_rotation)
why you decide to manipulate the Basis and not the rotation
It's always amazing to dive into something new. Nobody can take Godot from us - so learning it is no bet on some "benevolent" company. Thank you for the video! 👍
Very good tutorial Godot really needs more 3D content like this !
More to come!
I learned a lot! Thank you 🤓
I just started working with Godot and it's been great, I'm glad to see more tutorial videos with the engine. I haven't found a tutorial for how to filter over a 3D camera, like what those PS1-style horror games do. I've only found old videos for 2D games, It would be great if there was a tutorial.
Like a post processing effect?
@@stayathomedev Probably, honestly I don't really know what it is or is called. I just started with CS and deving so I'm pretty new too it, but like the closest thing I saw was some dude using a shader to pixelize a 2D sprite.
I just got there, i hope i'll get something like stairs climbing and slide and collide function.
Going to try to cover as much as possible as it progresses. Will try to branch out realistically to new topics as we create a solid FPS controller than you can also customize to your needs.
@@stayathomedev good luck!
Great vid although I wish some concepts of how the code works were more thoroughly explained (euler basis, transform, y axis is up and z axis is through the screen, so player rotation is rotation about the y-axis, and camera tilt is rotation about the x-axis, etc. )
This is great! Thank you!
Thank you for this
Great tutorial! I have a question though, you have set the type hint of the CAMERA_CONTROLLER variable to Camera3D, yet you reference the CameraController node which is a Node3D, I can't replicate this, nor does it make sense to me. Thanks for the video nevertheless!
Ah! Yes, I must have had the footage wrong. Node3D works fine, so you can reference either. But I will reference the parent node and not the actual camera node. So not Camera3D
Thanks for this tutorial, this is fantastic! Something I did notice with this though is that the mouse sensitivity winds up being tied directly to the frame rate. Because the `_unhandled_input()` method runs every frame, it store the mouse movement based on how far it's moved since the last frame. With a higher frame rate, this directly results in the mouse movement variables having a smaller value, which means that when the `_physics_process()` runs it will move the camera/player less than it would with a lower frame rate. I was able to verify this by coding in a max frame rate toggle that would alternate between running at 60fps and 360fps.
I think you can avoid this frame rate dependency by moving the camera movement logic into the `_unhandled_input()` method, but I am new enough to Godot that I'm not certain if there would be any downsides to doing it that way. Please correct me if I've missed something, I would love the opportunity to learn!
YES! I've need to fix this but haven't included it. I will probably do a refactor/fix video at some point and can include it. Good catch!
Please dont leave out weapon bob. There is no tutorial on You Tube that covers weapon bob.
Wouldn't dare...I'm going to cover as much as possible.
I added two other quality of life updates for debugging. A button to switch the mouse_mode from captured to visible and back and a label displaying the frames per second.
Here's the code for the mouse switch (obviously you have to add another button to your button mapping):
if event.is_action_pressed("switch_mouse_mode"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
Yes, I can finally make my dream game with this. Thankyou!
for some reason it says "Invalid access to property or key 'transform' on a base of type 'Nil'." can anybody help me out
same :(
I think i know what to do now, in 3d you go to characterbody3d and in the inspector you should see Camera controller somewhere at the top, click it and select your node you use as the neck
@@thegreatmightynerdOMG thanks bro
@thegreatmightynerd You are a true legend. This should be stated for anybody using 4.3+ versions.
@@thegreatmightynerd on god total life saver been sitting for 30 mins trying to figure out why this wont work
This was and instant like and subscribe for me. Your explanations are beautiful, adds so much to the video; i only had to watch it once instead of 3-4 times. On top of open source for the whole tutorial project.
Thank you!
Non of this worked for me can you please do an updated version for the latest version of godot 4 I have tryed this almost 7 time every step and even tryed my own methods but non of them worked
you can use a csg3dbox instead of mesh for the floor
This an amazing course
My Guy! :)
Hey, as someone coming from unity, these tutorials are super valuable right now so thank you very much ! Also I would like to ask if you are going to implement stair stepping functionality ? I have problems with finding decent solution and a lot of people are saying "just use slope" which I dont really consider as good solution. I really dont want to setup a slope for every little bump on the map.. that would be very annoying to do. Its really surprising to me, that there is no standardized solution for this in Godot since Unity has that in their CharacterController by default for ages.
Thanks! And that's definitely something that will be looked at.
There's a neat solution for stair stepping in Godot that, in theory sounded preposterous to me for a long time,... until I noticed Thief uses it, and that in practice it actually never bothered me that much (only a tiny bit): the solution is using a SeparationRayShape3D (in a ShapeCast3D node) under an elevated capsule (Thief used two vertical spheres). The nice thing about it is that the ray shape will handle stairs naturally on its own and push the player up the steps, or make it stick down the steps. You may still want to interpolate the camera movement, though.
The length of the separation ray defines the max height of climbable steps.
The downsides of this method are kind of obvious, but may not matter at all depending on the game.
- You will step down into tiny gaps. You don't get stuck, but if the floor has too many gaps it can be annoying (though the camera interpolation can reduce this).
- falling off ledges requires falling off twice, once for the ray and another for the player shape. It kinda feels like you fall on your butt before actually falling off the ledge.
- you will have trouble walking or landing on very small platforms, thin walls, and things of that nature.
One of the upsides, is that that you don't have to correct your maps to remove collisions from wall baseboards and that sort of stuff, because with this method players can't step onto that kind of thing at all.
I'm considering using this method for some horror games, that don't really require any ground precision, for example.
COOL !!!
I had an issue with the clamp where it did not stop spinning on the x axis. The z axis was already being reset so the camera stayed upright but it would flip backwards if I looked up! watched the camera segment probably over 12 times so I'm confident I copied it right, but I eventually found that it WOULD clamp... but not after 90 degrees, but probably closer to 90 radians, meaning it would stop after a lot of spinning. Fixed it by clamping it by -2 and 2 instead.
I can't believe it.
A coding/Game Dev tutorial that my ADHD agrees with!?!?
Nice tutorial. I solved most of these before seeing it, but I didn't know about captured mouse or that reflection probe node. I should add that to my game. I'm working on a movement shooter, mostly inspired by DOOM. Currently I just got half-pipes working properly, but if I run into the intersection of a vertical wall and flat floor I loose all of my speed instantly. I think it has something to do with how I bodged together conservation of momentum working with slopes.
Also, I spent ages figuring out how to get friction to vary depending on the player's angle relative to their movement angle, only to find in playtests that it's not particularly fun.
Interesting. I'd be curious to see that
I'm following this tutorial to a tee and it keeps giving errors very cool
wow this is going to be amazing!! I can't wait for this whole tutorial
Dude! Can you show us how to map these controls to a controller? The right stick to rotate and look around, in particular? All the other buttons are simple and straightforward, but that camera is a little tricky. I learned the mouse controls on Zenva already but I'm stuck on controller mapping
We'll go over controller setup for sure. The goal is to get a really solid controller setup (moving, sprinting, jumping, animations) then add controller option.
I'm trying to follow along with this awesome tutorial but in C# and I'm running into a problem. If you could help that would be amazing.
At 11:53 in line 46 you do:
global_transform.basis = Basis.from_euler(_player_rotation)
In C# that translates to:
GlobalTransform.Basis = Basis.FromEuler(_playerRotation);
However it says "Cannot modify the return value of 'Node3D.GlobalTransform' because it is not a variable."
Would you have any idea about this?
Just downloaded the project from github because for some reason the character won't move after following what you did and it still did not work. Inputs are correct and I have added the keybinds on both my project and the github project, I cannot see what could be going wrong
One question... after we fix camera rotation so the player rotates with it, the scene always starts with player facing the negative Z axis. Rotating the player body doesn't solve it, and I've noticed it happens in your tutorial as well. I'm using Godot 4.3. How can this be fixed? Rotating the CharacterBody on the level messes up the controls because it rotates only the camera, not the whole body.
Putting _update_camera(delta) in the _physics_update() function causes my camera to be very jittery. I assume this is because the physics_update is capped to 60. Did you not have this issue too? @StayAtHomeDev?
great tutorial : D
Something that I noticed about this particular implementation of mouse look, is that when you start the game the player is always looking in the same direction, regardless of which direction the player scene is facing in the level (IE, PlayerCharacter has been placed in the scene and was rotated 90 degrees). How exactly would this be fixed? It would be a very real problem for every player of a game (singleplayer OR multiplayer) to be looking Exactly North every time they load the game.
I fixed this (I think) by adding the following line to the _ready() function: _mouse_rotation = global_rotation
Very well explained! Only problem is that the script, copied and pasted straight from the repo, doesn't pick up any mouse movement. Printing rotation and tilt input leads to a sea of (0,0) vectors.
EDIT: Figured it out, I had a ColorRect gobbling up the mouse input. Make sure its mouse behavior isn't set to Stop in the inspector.
Good edits and good vibes!
And I really enjoyed it
But I feel having the goal of making it simple by not over-explaining, It made me feel a lot of it was just "magic codes" that I just had to copy and paste and none of it has any meaning
It makes me be scared of coding
I wished you explained every line of code a lot more
It's a fine line. I think in future, more focused, videos that more time can be spent on code. Thanks for your comments!
Im curious about the light probes. I dont have a ton of experience with light probes but in unity and unreal, I thought they were suppose to be static and it helped handle light data as the camera passed through them. Putting it on the camera sounds like potentially unneeded stress since the camera is needed for movement and the probes would be constantly moving and rotating. I wanted to ask about this since my major areas of noobness are light and shaders. Maybe godot functions differently when it comes to probes.
i am noob too but after reading documentation i thing you are correct.
Good luck to me, I'm start this course
:P
Dios mio yo hablo español y asi entiendo a que te refieres en el tutorial en verdad este es el mejor curso explicas todo a detalle dios tengo un proyecto batleroyal en godot que estoy comenzando aser nesesitaba un tutirial como este muchisimas gracias bro en serio gracias
Nice! This tutorial format is really good, looks super polished, and definitely feels inspired by Brackeys :) I hope this becomes a regular thing!
I'm curious why you're multiplying the mouse input by delta? Shouldn't mouse movement be absolute? I think what you want is a much lower sensitivity instead (normal sensitivity numbers are based on degrees not radians, which is why the math looks different from other engines). If you use delta, then at low frame rates your sensitivity will go way up.
Something to be looked at in another video I think to have time to explain the issue.
And thanks! Hoping the format works well. There was some inspiration :P
If anybody has a issue with running the code and you get error invalid get index 'transform' on base nil on the line CAMERA_CONTROLLER.transform.basis = Basis.from_euler(_camera_rotation).
try moving ( litteraly click and drag the 3d camera) back onto your Character body 3D. Worked for me! Just forget the extra node he made you create at the start
Wonderful tutorial, thank you for taking the time to make this! One question, I'm not sure why but every time I move my mouse the whole scene flickers... I think it's the reflection node we added. It might be a Godot 4.3 version problem... any help?
this channel gives me brackets vibe at some point is gonna get abadoned
Yes it works🎉🎉
But after 999999+ error 😂😂
This is just gonna become the default FPS template for most... Tutorials > Documentation at least for someone new like myself.
Yo this is a sick video so far but the func _unhandled_input(event) function on line 18 has multiple errors and says "expected expression after "==" operator" how do i fix it
Lol! Nevermind it was just a terribly stupid mistake!
@@GameChisel oh my gosh how did you get around this, it's driving me crazy, i copied it exactly
I'll try to find it but I don't remember lol XD
Tell me the time stamp@@Xer0Tr0n
Hi, very cool video, like definitely, there is a question whether the variables TILT_LOWER_LIMIT and TILT_UPPER_LIMIT can be set as a constant?
If it's constant then it can't be changed once the game starts.
Maybe you want all those values to be part of the game settings menu, then it's better to leave it as var and not as const.
You could if you really didn't want those to be adjusted...as the other commenter said...I think it becomes a customization issue and also not creating variable walls early on. May encounter a feature where the tilt needs to be narrowed or disabled for example.
So, I've just discovered this channel through Thomas Brush, he out a post about your channel. Im thinking about coming to Godot. Will this cover setting up enemies as well as the player character? You may have already done this but i have juat started watching.
Hey! The plan is to cover as much as possible, so definitely enemies. We're about to add weapons very shortly.
For some reason when i use the reflection probe and hdri the reflection light flickers a lot. I dont know why this is happening so im just going to use the procedural sky.
yeah, it is happening to me too!
also, it is a bad practice as it lower's fps. instead make the reflection probe static to only the places where it is required detached from the player.
hi! love the series, one question - when I use the grid shader for multiple objects as the material, if I change the albedo color of one, it does it for all of them. How can I separate this? Thanks!
What are eulers and basis
Been catching them a lot lately
Hi, would it be possible to get the project using compatability renderer instead of forward+?
My laptop doesn't support Vulkan unfortunately so I can't edit the project.
How do I use/apply your custom prototype grid material to my own meshes? I get "something" working but the tiling is wrong
At 10:04 on my thing I couldn’t move the camera with my mouse
Need this in C# :D
I'm contemplating it...it just would take me getting much more familiar with C#. But I think it's important to keep it in mind.
Will you do melee weapons and bows? I'm wondering if this would give me a good base for Kings Field like game. I'd have to figure out spells too... I'd guess lobbing a grenade would be quite similar to casting a spell?
Why do you use _ in front of variables?
Yes! And how's Jimmy G doin?
@@stayathomedev Sounds great! I think he'd be doing a lot better with a decent oline... :D
He's not a mover...(I'm a niners fan)
That he is not, lol. You guys are looking great. And Purdy is my new favorite! @@stayathomedev
I love that man. He's Purdy good 👍
when i turn it on it just doesn't work here's my code
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
@export var tilt_lower_limit := deg_to_rad(-90.0)
@export var tilt_upper_limit := deg_to_rad(-90.0)
@export var camera_controller : Camera3D
var mouse_input : bool = false
var mouse_rotation : Vector3
var rotation_input : float
var tilt_input : float
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _input(event):
if event.is_action_pressed("exit"):
get_tree().quit()
func _update_camera(delta):
mouse_rotation.x += tilt_input * delta
mouse_rotation.x = clamp(mouse_rotation.x, tilt_lower_limit, tilt_upper_limit)
mouse_rotation.y += rotation_input * delta
camera_controller.transform.basis = Basis.from_euler(mouse_rotation)
camera_controller.rotation.z = 0.0
rotation_input = 0.0
tilt_input = 0.0
func _unhandled_input(event):
mouse_input = event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED
if mouse_input:
rotation_input = -event.relative.x
tilt_input = -event.relative.y
print(Vector2(rotation_input,tilt_input))
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
_update_camera(delta)
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("left", "right", "up", "down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
idk what it is please help me
It may be too late now, but you need to call your camera node in your export variable. @onready var CAMERA_CONTROLLER : Camera3D = $CameraController/Camera3D #or whatever you named your camera nodes)
@@BigM11789 well i gave up on that
@UhhhhhStuffI figured I’d throw it out there anyway. Hopefully it’ll help you in the future or someone else!
@@BigM11789 i started game dev on unity cuz of the lack of godot tutorials
im stuck on rotating the camera, my camera just isn't moving even when i have the code correct, what do i do?
I don't get why we set _rotation_input to relative x mouse movement and _tilt_input to relative y movement, but then in _update_camera(delta) we set _mouse_rotation.x to _tilt_input and _mouse_rotation.y to _rotation_input. Is this not the opposite of what it should be? I mean, it works, but why?
Hey there! I am just getting into game-making, I'm wondering whether it's better to enroll in a programming course or dive into projects with the Godot game engine. What do you think is the way to go?
Honestly, go with whatever will keep you motivated. It's more about consistently working than the perfect path
Hi, I noticed a bug in the deceleration code. It appears that one axis can stop before the other. This can create an odd "sliding sideways" movement at certain angles as one axis will be completely stopped, but the other will still be decelerating. I don't have a fix for it, but just something I noticed in my own project.
top top top
I have a problem with the _update_camera(delta) line in physics process function. i have an error code saying nvalid get index transform on base nill. i made sure everything was typed correctly. please help
Did you set the export variable in the inspector?
@@stayathomedev i figured it how! i had a breakpoint! rookie moves 😅 ty!
@@user-el8oj2sq9t i had a break line in the coded. im not sure under ur circumstances.
how can I do this?
@@stayathomedev
I want to learn godot should i start with this Play list?
Hey loved the tutorial ! Just wanted to ask but am i the only one that has a weirdly low fps end result ? When trying with other tutorials it doesn't. It seems to happen during the camera script set up, if anyone knows if it's normal i'm taking it
i got this error
Invalid get index 'transform' (on base: 'Nil').
did anyone else and how can i fix it?
wait nvm, fixed it
@@FriskDreemurr66669 what did you do?
@@bryceowens-roberts8838 it's ok, i fixed it.
@@FriskDreemurr66669 How did you fix it?
@@coolik23 i think it was that i forgot to set an @export variable, i dont remember since this was a while ago