gdquest-demos / godot-4-3d-third-person-controller Goto Github PK
View Code? Open in Web Editor NEWGodot 4 demo with a plug-and-play 3D Third-Person Shooter (TPS) character controller inspired by games like Ratchet and Clank.
License: MIT License
Godot 4 demo with a plug-and-play 3D Third-Person Shooter (TPS) character controller inspired by games like Ratchet and Clank.
License: MIT License
This would show how to generate geometry, which is great for users, also a solution that can offer higher performance and greater control than CSGMesh (at least when using C++? Gotta benchmark in GDScript).
Higher priority:
Lower priority:
When I punch a wooden box/crate, the game crashes with that error.
I wanted to try the project out as it looks great, but doesn't seem to be working. I also can't seem to collide with or jump on the snowy ledges - the character just falls through.
Godot version 4.1.1 (I also tried Godot 4.0 and had the same issue.).
Windows 11
We have a photo mode right now to take screenshots and debug: CameraMode.gd. We should turn this into a third-party addon.
Notes:
Using a variety of layers and masks adds a dependency to anyone looking to reuse the character, and a kind of hidden way in which the character works for Godot beginners (NB: people can be Godot beginners AND experienced developers).
We talked about using multiple layers VS not and to make the demo a bit more accessible and the character a bit easier to copy into new projects, we decided to go with a single layer and mask, as it's easier for people to change later and tailor to their project.
Tasks:
When I download and run this project in Godot v4.03, I get the following error:
Edit:
This only happens with the files downloaded from here:
https://www.gdquest.com/news/2022/12/godot-4-third-person-controller/
When I download the repo, everything works fine.
Bullet particles and grenade explosion particles flicker when instancing new ones.
Related issues:
FYI there's no export for mac. The gdquest website also only exports a game.ini in a zip.
The problem is that godot4 has some issues [one of them] for some more complex shader parameters using Vulkan.
One easy way to get this (excellent controller btw, so thanks for that) to work for Mac (m1 in my case) godot users is to edit the project.godot file not to open the main scene directly (which would make the editor hang):
run/main_scene="res://Main.tscn"
to run/main_scene=""
And then in the editor itself changing to the compability rendering method or in the godot file:
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
This works on my godot 4.2.2 as well as godot 4.3 beta 1
Every time I test this demo, I run into weird issues with res://Enemies/smoke_puff/smoke_ball.tres
which gets corrupted. I've seen it happen on Linux, and now also on Windows 10.
Some issues might be attributed to upgrading to Godot 4.1.1 when this demo was last updated for Godot 4.0, so I'm doing my testing with Godot 4.0.4 for now to try to get to a relatively stable base before offering an upgrade to 4.1.
After cloning the repo and running it for the first time with 4.0.4, I had these warnings:
WARNING: res://Player/Coin/CoinVisuals/CoinModel.tscn:3 - ext_resource, invalid UID: uid://dqbsd44l6f1xi - using text path instead: res://Player/Coin/CoinVisuals/CoinModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Player/CharacterSkin.tscn:5 - ext_resource, invalid UID: uid://bbishx00t2kip - using text path instead: res://Player/model/materials/face_mat.tres
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.tscn:3 - ext_resource, invalid UID: uid://n4c3p8bt5sb1 - using text path instead: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Box/Box.tscn:4 - ext_resource, invalid UID: uid://cdtq6fyl7hhgm - using text path instead: res://Box/BoxVisuals/BoxModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Enemies/BeeBot.tscn:4 - ext_resource, invalid UID: uid://d28tem7s0fqin - using text path instead: res://Enemies/BeeBot/bee_root.tscn
at: load (scene/resources/resource_format_text.cpp:448)
But the game ran fine.
After closing the editor, and editing the game again, I now get an error with the aforementioned smoke_ball.tres
:
ERROR: res://Enemies/smoke_puff/smoke_ball.tres:4 - Parse Error:
at: load (scene/resources/resource_format_text.cpp:510)
ERROR: Failed loading resource: res://Enemies/smoke_puff/smoke_ball.tres. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:222)
WARNING: res://Player/Coin/CoinVisuals/CoinModel.tscn:3 - ext_resource, invalid UID: uid://dqbsd44l6f1xi - using text path instead: res://Player/Coin/CoinVisuals/CoinModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Player/CharacterSkin.tscn:5 - ext_resource, invalid UID: uid://bbishx00t2kip - using text path instead: res://Player/model/materials/face_mat.tres
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.tscn:3 - ext_resource, invalid UID: uid://n4c3p8bt5sb1 - using text path instead: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Box/Box.tscn:4 - ext_resource, invalid UID: uid://cdtq6fyl7hhgm - using text path instead: res://Box/BoxVisuals/BoxModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Enemies/BeeBot.tscn:4 - ext_resource, invalid UID: uid://d28tem7s0fqin - using text path instead: res://Enemies/BeeBot/bee_root.tscn
at: load (scene/resources/resource_format_text.cpp:448)
Changes have been made in Godot 4 so that this project doesn't work in the latest version of Godot.
I'd like to see the camera rotation improved in GDQuest's third-person controller. Currently, it's affected by framerate. If you turn off VSync and set max fps to 1000 (or another high number) then if you get around 400 FPS (try an empty scene) you can see the camera rotation speed become very slow. Likewise limiting to 10 FPS will speed up the camera rotation.
I noticed you multiply the rotation_input by the delta time of the physics process. This doesn't do anything though since the physics process function is fairly statically called. If you place the code to move the camera in the _process then the delta is representative of the current frame rate and thus your camera will no longer be affected by framerate.
If this is a change you'd like to see made, I'd be happy to make it.
Using Godot 4.0 stable on Windows 10.
If you are on the pause menu, and you press the "Esc" key twice very fast, the game will unpause and pause again very fast, but won't show the menu. So the game will be paused, but you won't be able to see the pause the menu. Pressing "Esc" again after this behaviour will unpause the game again without any issues, and the game will keep to behave normally.
Every time the main scene is saved, this value in the heart_core_mat.tres
material changes:
diff --git a/Player/model/materials/heart_core_mat.tres b/Player/model/materials/heart_core_mat.tres
index ec92b25..7eb6d28 100644
--- a/Player/model/materials/heart_core_mat.tres
+++ b/Player/model/materials/heart_core_mat.tres
@@ -4,4 +4,4 @@
albedo_color = Color(0, 0, 0, 1)
emission_enabled = true
emission = Color(0, 1, 0.392157, 1)
-emission_energy_multiplier = 0.669953
+emission_energy_multiplier = 1.2208
diff --git a/Player/model/materials/heart_core_mat.tres b/Player/model/materials/heart_core_mat.tres
index 7eb6d28..9d3e649 100644
--- a/Player/model/materials/heart_core_mat.tres
+++ b/Player/model/materials/heart_core_mat.tres
@@ -4,4 +4,4 @@
albedo_color = Color(0, 0, 0, 1)
emission_enabled = true
emission = Color(0, 1, 0.392157, 1)
-emission_energy_multiplier = 1.2208
+emission_energy_multiplier = 2.16216
This messes up the git history but also actually changes the material. Might be a Godot bug, but I'm reporting it here first to debug.
Seen with Godot 4.0.4, and 4.1.1.
Description: Missing textures in Linux/X11 version. Most likely related to shaders.
Game version: linux-x11-main-1.0.0-e99f017
OS: Debian GNU/Linux 11 (bullseye) x86_64
Log: godot.log
I would love to help contribute a toggleable follow camera option (like mario / uncharted) - when the player does not provide look direction input for X seconds, the camera autofollows the player direction. I have implemented this in a separate project, but would like to know if there is a preferred way you would like me to approach this for this project.
General approach in my other project:
In player script, when follow camera is on and _camera_controler.mouse_has_not_been_touched and player is_moving, (not aiming), have the camera follow the player.
Please let me know objections/considerations.
EDIT: the project was updated to beta 17 in #13
Now, most animations work fine. Only the beetle's animation tree doesn't play well.
In Godot 4 beta 10 animations don't work properly, Godot's throwing this error:
EDIT: this error is fixed, but animations still don't work as intended. We recommend using beta 7/8 until this is fixed
This error occurs on the latest download from the package on MacOS.
Anyone know how do you fix this type error?
Line 39:Cannot infer the type of "next_location" variable because the value doesn't have a set type.
Line 42:Cannot infer the type of "direction" variable because the value doesn't have a set type.
39 var next_location := _navigation_agent.get_next_location() // *** RED
if not _navigation_agent.is_target_reached():
42 var direction := (next_location - global_position) // *** RED
direction.y = 0
direction = direction.normalized()
Trying to edit the current main
commit d2f35ef in Godot 4.0-rc (6cde3fac328e97e66b1c12d386deb25af395e215), I get the following load errors (on the second editor run, the first one is full of errors like Godot tends to be when the .godot
folder isn't there yet):
ERROR: Can't open file from path 'res://models/shared/shaders/screen_shader.gdshader'.
at: get_file_as_bytes (core/io/file_access.cpp:699)
WARNING: res://Enemies/beetle_bot/materials/beetlebot_eyes_mat.tres:4 - ext_resource, invalid UID: uid://bvxkh2pa1nqdq - using text path instead: res://models/shared/textures/eye_mask.png
at: load (scene/resources/resource_format_text.cpp:448)
ERROR: Resource file not found: res://models/shared/textures/eye_mask.png.
at: _load (core/io/resource_loader.cpp:226)
ERROR: res://Enemies/beetle_bot/materials/beetlebot_eyes_mat.tres:15 - Parse Error: [ext_resource] referenced non-loaded resource at: res://models/shared/textures/eye_mask.png
at: _parse_ext_resource (scene/resources/resource_format_text.cpp:174)
ERROR: res://Enemies/beetle_bot/materials/beetlebot_eyes_mat.tres:15 - Parse Error: [ext_resource] referenced non-loaded resource at: res://models/shared/textures/eye_mask.png
at: load (scene/resources/resource_format_text.cpp:735)
ERROR: Failed loading resource: res://Enemies/beetle_bot/materials/beetlebot_eyes_mat.tres. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:221)
ERROR: res://Enemies/smoke_puff/smoke_ball.tres:4 - Parse Error:
at: load (scene/resources/resource_format_text.cpp:510)
ERROR: Failed loading resource: res://Enemies/smoke_puff/smoke_ball.tres. Make sure resources have been imported by opening the project in the editor at least once.
at: _load (core/io/resource_loader.cpp:221)
WARNING: res://Player/Coin/CoinVisuals/CoinModel.tscn:3 - ext_resource, invalid UID: uid://dqbsd44l6f1xi - using text path instead: res://Player/Coin/CoinVisuals/CoinModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.tscn:3 - ext_resource, invalid UID: uid://n4c3p8bt5sb1 - using text path instead: res://JumpingPad/JumpingPadVisuals/JumpingPadModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
WARNING: res://Box/Box.tscn:4 - ext_resource, invalid UID: uid://cdtq6fyl7hhgm - using text path instead: res://Box/BoxVisuals/BoxModel.glb
at: load (scene/resources/resource_format_text.cpp:448)
There's indeed no models
folder in the repo.
Although a simple mistake and not generally important, I thought I'd point out that the export variable in JumpingPad.gd is written as "impulse_strenght
" instead of "impulse_strength
".
Not really an issue, just a question, why is this project not using hitbox/hurtbox nodes? I understand that maybe because it's a "small" project, so it's not required, but it would've been good to have it just for learning purpose.
I'm unsure of if there are further errors hidden behind the ones that are logged, but I don't know how to fix the existing ones myself to check.
Godot Engine v4.0.2.stable.official.7a0977ce2 - https://godotengine.org
Vulkan API 1.3.224 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 3060 TiUSER WARNING: res://Player/Grenade.tscn:4 - ext_resource, invalid UID: uid://d5jny5gc8ntg - using text path instead: res://Player/GrenadeVisuals/grenade/grenade.tscn
at: load (scene/resources/resource_format_text.cpp:448)
--Main Shader--
1 | shader_type spatial;
2 |
3 | uniform vec3 shallow_color : source_color;
4 | uniform vec3 deep_color : source_color;
5 | uniform vec3 foam_color : source_color;
6 | uniform float water_scale = 1.0;
7 | uniform float time_scale = 100.0;
8 | uniform sampler2D noise_sampler : hint_normal;
9 | uniform sampler2D small_waves_sampler : hint_normal;
10 |
11 | uniform sampler2D foam_noise : hint_normal;
12 |
13 |
14 | float fresnel(vec3 normal, vec3 view, float intensity){
15 | return pow(1.0 - clamp(dot(normal, view), 0.0, 1.0), intensity);
16 | }
17 |
18 | void fragment() {
19 |
20 |
21 | vec2 scaled_uv = UV * water_scale;
22 | float scaled_time = TIME / time_scale;
23 |
24 |
E 25-> float _log_depth = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).x;
26 | vec3 _depth_ndc = vec3(SCREEN_UV * 2.0 - 1.0, _log_depth);
27 | vec4 _depth_view = INV_PROJECTION_MATRIX * vec4(_depth_ndc, 1.0);
28 | _depth_view.xyz /= _depth_view.w;
29 | float linear_depth = -_depth_view.z;
30 |
31 | float depth = VERTEX.z + linear_depth;
32 | depth *= 0.2;
33 | depth = clamp(depth, 0.0, 1.0);
34 |
35 | float foam_n = texture(foam_noise, scaled_uv + scaled_time).x;
36 |
37 | float foam_mask = smoothstep(0.0, 0.5 * foam_n, depth);
38 |
39 | vec3 screen_color = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
40 |
41 | vec3 screen_color_depth = mix(screen_color * shallow_color, deep_color, depth);
42 |
43 | vec3 water_color = mix(screen_color_depth, deep_color, fresnel(NORMAL, VIEW, 2.0));
44 |
45 | ALBEDO = mix(foam_color, water_color, foam_mask);
46 | ROUGHNESS = 0.02;
47 | SPECULAR = 1.0;
48 |
49 |
50 | vec3 normal_map = texture(noise_sampler, scaled_uv + scaled_time).rgb;
51 | vec3 small_waves = texture(small_waves_sampler, scaled_uv - scaled_time).rgb;
52 |
53 | NORMAL_MAP = mix(normal_map, small_waves, 0.5);
54 | NORMAL_MAP_DEPTH = 0.25;
55 | }
56 |
USER SHADER ERROR: DEPTH_TEXTURE has been removed in favor of using hint_depth_texture with a uniform.
To continue with minimal code changes add 'uniform sampler2D DEPTH_TEXTURE : hint_depth_texture, filter_linear_mipmap;' near the top of your shader.
at: (null) (:25)
USER ERROR: Shader compilation failed.
at: set_code (servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp:137)
USER ERROR: Condition "!version" is true. Returning: RID()
at: version_get_shader (./servers/rendering/renderer_rd/shader_rd.h:140)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.