The function get_axis(negative, positive) would be used to set the input Vector3. Since, we will be controlling the velocity along y through gravity, we don't need any input for that. So, we'll set it to 0.
Great tutorial! There is definitely a lack of 3D Godot content and this was clear and very well done! You should consider making a video on how to set up a simple level like this one.
I LOVE that you made this specific video. When making an FPS it's the foundation for your character and it's very appreciated. I took notes on all of the code and now have a baseline to reference to for any upcoming FPS projects!
Your tutorial is easy to understand and it immediately worked for me first try, unlike other times i've used tutorials and struggled to make them work. Thanks a lot, Nagi!
Hi! In case you're using Godot 4, I've posted a new video specifically for making an FPS controller in Godot 4. Be sure to check it out if you want! Also, I'm glad I could help!
When I implemented the gravity, there was an error that was that it couldn't convert Vector3 to float: velocity.x = lerp(velocity.x, MoveDir * speed, accel * delta) velocity.z = lerp(velocity.z, MoveDir * speed, accel * delta) velocity = move_and_slide(velocity, Vector3.UP) what did I do wrong?
i want to learn how to code without logic nodes, it's being a pain in the ass, thanks for this tutorial! (suggestion: explain more about script terms for newbies like me, example what is Vector3 and what does it means, and why you need to put a .ZERO after, avoiding people to google these stuff)
I understand. My videos are more geared towards intermediate Godot developers. I'm planning on doing Godot 4 tutorials next and will be focussing it for Godot beginners. I hope it'll help you! Stay tuned!
Hi Nagi, First of all, great content. I'm fairly new to Godot and quickly learned that its fanbase(users) is fairly small still. I followed along with your tutorial and everything seems great. The only thing I am struggling with is that when I move with a/w/d/s respectively, they seem to be stuck to the initial direction of the 3-dimensional space. Let me rephrase: I would like to know if there would be a way to make the W always go forward respectively to the camera view for instance, or is this a bad/dumb practice? Would love to hear something back. I am using your tutorials for an art school project! :)
Hey N P, If you mean to say you want the player to always move along the global axis when pressing the key, not taking the camera rotation into the calculation. Then, all you need to do is skip the .rotated() call. We're using the .rotated() function call to convert the input direction (which is in global coordinates) into the player's local coordinates.
If you ever got stuck on this, I believe what you might have done is accidentally put "head." before your rotation_degrees.y, which locks the movement directions to the cardinal directions rather than reactive to the camera.
I have an issue, The movement is working fine, But When i try to look up or down, It looks like the camera arcs forward and zooms in, I don't know what to do
for some reason, I have a problem with the jump being consistent. Sometimes it doesn't jump, and I assume it has to do with the is_on_floor check as it works if I don't check that (but then obviously you can infinity jump).
I had the same problem. I fixed it by changing "is_action_just_pressed" to "is_action_pressed" for "jump". Not sure if this will have any downstream repercussions, but it worked.
@@AlexanderTersakian is_action_just_pressed only work on the frame you pressed the button, while is_action_pressed stays true as long as the button is pressed. This means the player will keep jumping as long as you keep the key pressed down.
Uh when I tried doing the gravity part, I ran the game and then I fell right through the floor. I tried making the floor very thick but it still made me fall right through. Could you help me?
Is the floor a StaticBody with a CollisionShape child? If so, does the collision layer / mask for both the player and the floor have any layer in common?
You could use Godot 3.5. Or you could wait for me to post a tutorial for Godot 4.0 explaining everything in detail. The code required for kinematic body motion has been changed, so you will have to set the value of the in-built variable `velocity` and then call move_and_slide() as is without any parameters.
Soooo For some reason my up down look are inverted and so are my moving forwards and backwards idk why I did everything as u did Any help would be appreciated
for some reason it doesn't register is_on_floor() when i'm on the floor, but thinks i'm is_on_wall() instead somehow (even seems to is_on_floor() when my head hits the ceiling) what do update: now is_on_floor() is just flipping between the two states every frame
Bro it say that in line 3 there is an unexpected identifier in class body and i don't know how to fix it can you pls say the fix and I am also using godot 4
so far im putting everything in right but when i open the scene its not working. the the 'head' / camera is a error. its says get_node: (node not found: head ( relative to /root/root/camera2/player) what can i do to fix this ?
Can you check if your player scene has a node called "Head" making sure all capital and small letters match? You player scene should be like: Player -CollisionShape -Head --Camera and your code should have onready var head = $Head Also, make sure the player script is attached to the Player node. It's common mistake to attach the script to some other node in the scene accidentally. In the scene tree, check if the script icon shows in the Player node. If it's not there you should find the node where the script is attached, remove the script, select the Player node and attach the script to this node.
I was going to give you a written answer, but now I think I'll make a tutorial about it. But if you want a quick answer, you'll have to add some input_maps with each joystick axis (up, down, left, right) and then do Input.get_vector(). Use this input axis to change the look_rot vector.
There's a bunch of different ways to make a map, for this tutorial I used Blender to create the mesh for the map, exported it as a gltf file and imported it into Godot. If you're not familiar with 3D modeling, you can use free assets available online. My recommendation would be Kenny's Assets!
@@NagiDev i tried copy just the overworld scene into my project being lazy to create my own level The materials didn't apply for the models and i got an error saying that the materials used for the level is not found in the original directory from your project Also blender and godot really hate me whenever I try to do anything in 3d
What version of Godot are you using? What exact issue are you facing? Are they any errors in the console? Please let me know and I'll my best to fix it.
@Daan I haven't worked much with groups :/ Although, the way I handle weapons and guns is by setting enemies and weapons to their own collision layers/masks and/or setting the enemy to it's own class and checking if the gun is colliding with the object of the enemy class/collision layer. (I think I should make a tutorial about it soon)
event.relative.x gives us the mouse motion along the screen's x axis (horizontal) which should rotate the player along its y axis. Similarly relative y should rotate along player's x axis.
Line number 22 and 24 can be further simplified as follows,
Input.get_axis("left", "right"), 0, Input.get_axis("forward", "backward")
Oh right, I forgot about that! Thank you so much! You're awesome!
Oh wow
What does that 0 mean?
The function get_axis(negative, positive) would be used to set the input Vector3. Since, we will be controlling the velocity along y through gravity, we don't need any input for that.
So, we'll set it to 0.
@@NagiDev ah alr
defiantly the easiest tutorial yet on RUclips about Godot 3d fps movement thank you so much.
Great tutorial! There is definitely a lack of 3D Godot content and this was clear and very well done! You should consider making a video on how to set up a simple level like this one.
Lack of what content? What have you searched for?
@@NeZversSounds In my experience its been far easier to find clear cut beginner tutorials for 2D content in Godot.
I LOVE that you made this specific video. When making an FPS it's the foundation for your character and it's very appreciated.
I took notes on all of the code and now have a baseline to reference to for any upcoming FPS projects!
Your tutorial is easy to understand and it immediately worked for me first try, unlike other times i've used tutorials and struggled to make them work. Thanks a lot, Nagi!
Hi! In case you're using Godot 4, I've posted a new video specifically for making an FPS controller in Godot 4. Be sure to check it out if you want!
Also, I'm glad I could help!
Hi! Thank you for your tutorial! It's short but very informative (which is great since I've needed it in like 5 min before deadline)
Thank you so much! I have been struggling to find tutorials on this topic, but this one actually worked
Awesome video, I was very easily able to add sprinting to this script.
absolutely great tutorial. I really hope you make more!
Dude! You're a Legend👑for this!✨👌
Thanks for this! Was really easy to add bob and stuff with sine
Man, new sub.
You explained it so well
This is a really great tutorial! Thank you! Maybe a third person animated controller next?
I believe Johnny Rouddro does a great job of explaining that, but if I feel the need for an updated tutorial, I'll surely make one. Stay tuned!
When I implemented the gravity, there was an error that was that it couldn't convert Vector3 to float:
velocity.x = lerp(velocity.x, MoveDir * speed, accel * delta)
velocity.z = lerp(velocity.z, MoveDir * speed, accel * delta)
velocity = move_and_slide(velocity, Vector3.UP)
what did I do wrong?
What version of Godot are you using?
@@NagiDev 3.5
You didn't write .x and .z after MoveDir.
You code should look like:
velocity.x = lerp(velocity.x, MoveDir.x * speed, accel * delta)
velocity.z = lerp(velocity.z, MoveDir.z * speed, accel * delta)
@@NagiDev Thank you so much 😁
great tutorial!
i want to learn how to code without logic nodes, it's being a pain in the ass, thanks for this tutorial! (suggestion: explain more about script terms for newbies like me, example what is Vector3 and what does it means, and why you need to put a .ZERO after, avoiding people to google these stuff)
I understand. My videos are more geared towards intermediate Godot developers. I'm planning on doing Godot 4 tutorials next and will be focussing it for Godot beginners. I hope it'll help you! Stay tuned!
Enjoyed. +SUB! waiting for more, like movement camera, like in Dark souls games. THX Friend!
Awesome!!!!
This is good. We need more 😅
u are the best!
Please make more :D
I did :3
@@NagiDev i know. great presentation. i can't wait for next video.
Hi Nagi,
First of all, great content. I'm fairly new to Godot and quickly learned that its fanbase(users) is fairly small still. I followed along with your tutorial and everything seems great. The only thing I am struggling with is that when I move with a/w/d/s respectively, they seem to be stuck to the initial direction of the 3-dimensional space. Let me rephrase: I would like to know if there would be a way to make the W always go forward respectively to the camera view for instance, or is this a bad/dumb practice? Would love to hear something back. I am using your tutorials for an art school project! :)
Hey N P,
If you mean to say you want the player to always move along the global axis when pressing the key, not taking the camera rotation into the calculation. Then, all you need to do is skip the .rotated() call. We're using the .rotated() function call to convert the input direction (which is in global coordinates) into the player's local coordinates.
If you ever got stuck on this, I believe what you might have done is accidentally put "head." before your rotation_degrees.y, which locks the movement directions to the cardinal directions rather than reactive to the camera.
your the best programmer
I have an issue, The movement is working fine, But When i try to look up or down, It looks like the camera arcs forward and zooms in, I don't know what to do
can you check if the camera is at the position (0, 0, 0) relative to the head node?
for some reason, I have a problem with the jump being consistent. Sometimes it doesn't jump, and I assume it has to do with the is_on_floor check as it works if I don't check that (but then obviously you can infinity jump).
Did you set the physics to Godot physics in the project settings? Also, did you pass the vector3.UP in the move and slide function call?
I had the same problem. I fixed it by changing "is_action_just_pressed" to "is_action_pressed" for "jump". Not sure if this will have any downstream repercussions, but it worked.
@@AlexanderTersakian is_action_just_pressed only work on the frame you pressed the button, while is_action_pressed stays true as long as the button is pressed. This means the player will keep jumping as long as you keep the key pressed down.
How did you make the villager look at you?
look_at()
How do you make it so you can jump infinetly? bc an character can fly in an game i am working on
For that you can define a flag variable (a variable that's either true or false) and toggle it anytime you want to fly
for the jump logic, just remove the face they have to be on the floor to jump, only when they press jump
❤❤❤
Love U ❤♥❤
Uh when I tried doing the gravity part, I ran the game and then I fell right through the floor. I tried making the floor very thick but it still made me fall right through. Could you help me?
Is the floor a StaticBody with a CollisionShape child?
If so, does the collision layer / mask for both the player and the floor have any layer in common?
@@NagiDev I made the floor a csgbox.
@@listed7568 did you enable collisions from the inspector?
@@NagiDev Oh. It works now I turned it on lol
I am getting the error too many arguments for move_and_slide expected 0 but got 1
You are probably using Godot 4. This tutorial is for Godot 3.
@@NagiDev do you know how to fix
You could use Godot 3.5. Or you could wait for me to post a tutorial for Godot 4.0 explaining everything in detail.
The code required for kinematic body motion has been changed, so you will have to set the value of the in-built variable `velocity` and then call move_and_slide() as is without any parameters.
Soooo For some reason my up down look are inverted and so are my moving forwards and backwards idk why I did everything as u did
Any help would be appreciated
This could likely be due to accidentally switching up and down in one of the Input functions, or maybe a misplaced +/- ?
@@NagiDev idk I’ve looked over the code a few hundred times but I’ll recheck it (I’m using this code in a passion project)
@@samfrank910 let me know if I can take a look at the code. I'll be glad to help!
how do i fix jump sometimes not being detected
change the physics engine in the project settings to Godot physics
for some reason it doesn't register is_on_floor() when i'm on the floor, but thinks i'm is_on_wall() instead somehow (even seems to is_on_floor() when my head hits the ceiling)
what do
update: now is_on_floor() is just flipping between the two states every frame
I think either the gravity you apply is too low or you're not passing the UP vector in move_and_slide.
Bro it say that in line 3 there is an unexpected identifier in class body and i don't know how to fix it can you pls say the fix and I am also using godot 4
This tutorial is for Godot 3. It won't work on Godot 4
Change it from export to @export that should fix it
so far im putting everything in right but when i open the scene its not working. the the 'head' / camera is a error. its says get_node: (node not found: head ( relative to /root/root/camera2/player) what can i do to fix this ?
Can you check if your player scene has a node called "Head" making sure all capital and small letters match?
You player scene should be like:
Player
-CollisionShape
-Head
--Camera
and your code should have
onready var head = $Head
Also, make sure the player script is attached to the Player node. It's common mistake to attach the script to some other node in the scene accidentally. In the scene tree, check if the script icon shows in the Player node. If it's not there you should find the node where the script is attached, remove the script, select the Player node and attach the script to this node.
the map wont show up when i tried it
hi can you please elaborate what issue you're facing?
@@NagiDev it just doesnt show up, i think i just put it on a different scene and it didnt show because the other was main scene
@@etfwe you can try instancing the map scene on your main scene or set the map scene as the main scene from the project settings.
is there a way to make the camera work with the joystick?
I was going to give you a written answer, but now I think I'll make a tutorial about it.
But if you want a quick answer, you'll have to add some input_maps with each joystick axis (up, down, left, right) and then do Input.get_vector(). Use this input axis to change the look_rot vector.
I can’t find special node anywhere
Can you please elaborate which special node you're talking about?
I dont know why but nothing works
please help
Sure, can you please explain what issue you're facing and what system/Godot version you're working with?
how do i make my own map
There's a bunch of different ways to make a map, for this tutorial I used Blender to create the mesh for the map, exported it as a gltf file and imported it into Godot.
If you're not familiar with 3D modeling, you can use free assets available online. My recommendation would be Kenny's Assets!
how did you make the overworld
Blender
That explains why everything broke when tried importing the level
@@codeimagine6824 I don't quite understand. Can you please explain the issue to me?
@@NagiDev i tried copy just the overworld scene into my project being lazy to create my own level
The materials didn't apply for the models and i got an error saying that the materials used for the level is not found in the original directory from your project
Also blender and godot really hate me whenever I try to do anything in 3d
I can't move at x axis can someone help
Which Godot version are you using?
3.5
Can you please check if you might've missed or misspelt something in the code?
@@NagiDev it's fine now thanks
WHY IS MY MOUSE STILL showing and still moving]
Which Godot version are you using?
is the scenario a single exported object?
I'm not sure what you mean. But the end result is a scene+script that you can use in any of your project
Line 27 and 32 is error
Hey, can you please share what the error says?
@@NagiDev sorry not 27 but 34 and 40
Hey there again, it would be really helpful if you can share the error message instead of the line number
@@NagiDev line 34: Expected statement, found "Indent" instead.
@@NagiDev line 40 Expected end of file.
i treid but it wouldnt work qwq
What version of Godot are you using? What exact issue are you facing? Are they any errors in the console? Please let me know and I'll my best to fix it.
I am not smart enough for this
I feel you. Just keep trying and you'll find it easy in no time. Best wishes!
i get an error. Parse Error: Static constant 'up' not present in built-in type Vector3.
modules/gdscript/gdscript.cpp:583 - Method failed. well that
nevermind it works, dumb mistake. Great tutorial!
no worries we all make mistakes. Glad I could help!
@@NagiDev I am making a gun now but the "is_in_group" function is not passing. The enemy is in the group tho. Let me know if you can help.
@Daan I haven't worked much with groups :/
Although, the way I handle weapons and guns is by setting enemies and weapons to their own collision layers/masks and/or setting the enemy to it's own class and checking if the gun is colliding with the object of the enemy class/collision layer.
(I think I should make a tutorial about it soon)
@@NagiDev That would be great. Can you tell me how to implement it?
I didn't understand why look_rot.y receives value from event.relative.x, and lookrot.x receives value from event.relative.y
event.relative.x gives us the mouse motion along the screen's x axis (horizontal) which should rotate the player along its y axis. Similarly relative y should rotate along player's x axis.