Godot First Person Controller
A downloadable Godot 4 Base Project
Basic First Person Controller for Godot 4
This is a Godot 4 base project that can be used for games with First Person perspective.
Only about 70 lines of code written in optimized GDScript 2.0.
Movement calculation is independent from FPS. The player will move and rotate the camera at the same speed at any frame rate.
You can tweak the player values directly in the editor:
- Speed (m/s)
- Acceleration (m/s^2)
- Jump height (approx. m)
- Camera Sensitivity
The player movement is calculated as the result of vector forces:
- Walk velocity
- Gravity velocity
- Jumping velocity
There is a Sandbox.tscn scene that is used as the main scene of the project just to test the FPC, you can do whatever you want with it.
Also there are two functions included to capture de mouse (lock the mouse on the screen) or release it when needed: capture_mouse() and release_mouse().
If you like this project please give me a star on Github!
🔗 Links
⚖️ License
This project is under the CC0 license, so you can use it for whatever you want on personal or commercial project. Recognition is not needed but is very much appreciated. You can reference me on Threads: @rbarongr and give me a follow there.
🎮 Controls
Keys | Action Name | Description |
W, left stick up | move_forward | Move forward |
S, left stick down | move_backwards | Move backwards |
A, left stick left | move_left | Move to the left |
D, left stick right | move_right | Move to the right |
mouse, right stick | look_ + dir | Look/Aim |
Space, Xbox Ⓐ | jump | Apply jump force |
Esc, Xbox Ⓑ | exit | Close the game |
You can change any of this keys in: Project Settings → Input Map.
Maybe you are interested in some low poly first person arms. 👐
Status | Released |
Category | Assets |
Rating | Rated 5.0 out of 5 stars (6 total ratings) |
Author | rbgr |
Tags | addon, Controller, First-Person, fpc, FPS, fps-template, Godot, plugin, Singleplayer, Project template |
Download
Click download now to get access to the following files:
Development log
- New v3.1.1!Sep 21, 2023
- New v3.1! 🥳Jul 06, 2023
- New v3 with 🎮 controller/gamepad support!Feb 06, 2023
- Basic FPC for Godot 4 released!Dec 13, 2022
Comments
Log in with itch.io to leave a comment.
Thanks so much for this, I've been using this controller while I learn Godot! Small question, if the player node's starting rotation is 90 degrees (so it's facing the correct way within the scene), how can I avoid the controls also having 90 degree rotation applied? Or must the player node rotation always stay as 0, and I somehow rotate the scene 90 degree around the player? Thanks again!
Thank you for your support! 😄
And for your question… don’t rotate the scene around the player, just put the player and rotate that node. Why is the player rotation a problem? I’ve been using it in different scenes and didn’t found the rotation to be a problem 🙂
Even in the latest version of the project which I grabbed from github, WASD movement is rotated 90 degrees if the Player node was rotated 90 degrees within the world. I'm not sure why the rotation is a problem, but if it definitely works on your side then I'll keep digging to find out what I've missed :)
I will take a look at the problem in a few days, it may be a bug 🐛
Just found out, the camera was using local rotation instead of global. In line 60 camera.transform.basis should be camera.global_transform.basis. Fixed in the new version v3.1.1.
Amazing, thank you!
There are two things I'm trying to figure out with my copy of BasicFPC. I'm intending to solve these myself but I will also send the feedback here in case it's useful for you.
1. Handle head bumps so if the character's head hits the ceiling they don't hover.
2. Fix movement issues when using keyboard controls while PS4 controller is connected.
Anyway I'm just having fun with all this, and you've saved me a lot of time!
Having fun is the most important thing!
And about those issues…
Maybe try to use the is_on_ceiling() or is_on_ceiling_only() functions from CharacterBody3D? 🤔
What issues exactly? Stopping from moving of something like that?
If you are still having problems, right click on the player controller in the scene you are working with and hit "Make Local" and you then you can rotate the camera to change the direction that player is facing without messing with its movement
Hopefully this helps someone, I had a similar issue but was watching a video and saw someone do it.
Thank you for offering a solution 🫶
I just pushed a little update that should prevent any issues with the starting rotation of the player node (on the Y axis). The new version is the v3.1.1. 😊
Yea, no problem!
And thanks for upgrading the script, this means I won't have to do this everytime(or make different scenes for each rotation I want)
Thanks so much, maybe this will help me make in 3d again!