From f1cbea5b8a08518ad399e805ad1b95aa4cd870c9 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Tue, 3 Jan 2023 19:04:11 +0100 Subject: [PATCH] cleaned up project --- export_presets.cfg | 49 --------------------------------- project.godot | 6 ++-- scenes/main.tscn | 16 +---------- shader/debug1.tres | 29 ------------------- shader/debug2.tres | 28 ------------------- src/player.cs | 27 +++++++++--------- src/{essential.cs => window.cs} | 2 +- test 3d project.csproj.old | 7 ----- 8 files changed, 19 insertions(+), 145 deletions(-) delete mode 100644 export_presets.cfg delete mode 100644 shader/debug1.tres delete mode 100644 shader/debug2.tres rename src/{essential.cs => window.cs} (93%) delete mode 100644 test 3d project.csproj.old diff --git a/export_presets.cfg b/export_presets.cfg deleted file mode 100644 index c3c42e3..0000000 --- a/export_presets.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[preset.0] - -name="Windows Desktop" -platform="Windows Desktop" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -export_path="../../../Desktop/test3dproject.exe" -encryption_include_filters="" -encryption_exclude_filters="" -encrypt_pck=false -encrypt_directory=false -script_export_mode=1 -script_encryption_key="" - -[preset.0.options] - -custom_template/debug="" -custom_template/release="" -debug/export_console_script=2 -binary_format/embed_pck=true -texture_format/bptc=false -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false -texture_format/no_bptc_fallbacks=true -binary_format/architecture="x86_64" -codesign/enable=false -codesign/identity_type=0 -codesign/identity="" -codesign/password="" -codesign/timestamp=true -codesign/timestamp_server_url="" -codesign/digest_algorithm=1 -codesign/description="" -codesign/custom_options=PackedStringArray() -application/modify_resources=true -application/icon="" -application/console_wrapper_icon="" -application/icon_interpolation=4 -application/file_version="" -application/product_version="" -application/company_name="" -application/product_name="" -application/file_description="" -application/copyright="" -application/trademarks="" diff --git a/project.godot b/project.godot index a677f0a..0553ae6 100644 --- a/project.godot +++ b/project.godot @@ -10,16 +10,16 @@ config_version=5 [application] -config/name="test 3d project" +config/name="Godot Mono Thirdpersoncontroller" run/main_scene="res://scenes/main.tscn" -config/features=PackedStringArray("4.0", "C#", "Forward Plus") +config/features=PackedStringArray("4.0", "Forward Plus") run/max_fps=144 boot_splash/show_image=false config/icon="res://icon.svg" [autoload] -Essential="*res://src/essential.cs" +GlobalWindow="*res://src/window.cs" [display] diff --git a/scenes/main.tscn b/scenes/main.tscn index a79828c..132eab9 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,8 +1,6 @@ -[gd_scene load_steps=16 format=3 uid="uid://dqyb5g1lyurfj"] +[gd_scene load_steps=12 format=3 uid="uid://dqyb5g1lyurfj"] [ext_resource type="PackedScene" uid="uid://b2ncexsbkd2ca" path="res://scenes/player.tscn" id="1_1hi18"] -[ext_resource type="Shader" uid="uid://v3mxp45i58ws" path="res://shader/debug2.tres" id="1_b4a1p"] -[ext_resource type="Shader" uid="uid://ce67ji5dkjiiv" path="res://shader/debug1.tres" id="2_3p2fh"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_rubfc"] ground_bottom_color = Color(0.87451, 0.952941, 1, 1) @@ -20,24 +18,12 @@ ssr_fade_out = 2.21914 [sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_0vf24"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_0qhj1"] -render_priority = 0 -shader = ExtResource("1_b4a1p") -shader_parameter/ColorParameter = null - [sub_resource type="BoxMesh" id="BoxMesh_hmqcx"] -material = SubResource("ShaderMaterial_0qhj1") [sub_resource type="BoxShape3D" id="BoxShape3D_bxkt8"] size = Vector3(1, 1, 1.24943) -[sub_resource type="ShaderMaterial" id="ShaderMaterial_2hee6"] -render_priority = 0 -shader = ExtResource("2_3p2fh") -shader_parameter/ColorParameter = null - [sub_resource type="PlaneMesh" id="PlaneMesh_p3q8d"] -material = SubResource("ShaderMaterial_2hee6") [sub_resource type="BoxShape3D" id="BoxShape3D_pxtb0"] size = Vector3(1.994, 0.048, 2) diff --git a/shader/debug1.tres b/shader/debug1.tres deleted file mode 100644 index 7509993..0000000 --- a/shader/debug1.tres +++ /dev/null @@ -1,29 +0,0 @@ -[gd_resource type="VisualShader" load_steps=2 format=3 uid="uid://ce67ji5dkjiiv"] - -[sub_resource type="VisualShaderNodeColorParameter" id="VisualShaderNodeColorParameter_fmfod"] -expanded_output_ports = [0] -parameter_name = "ColorParameter" -default_value_enabled = true -default_value = Color(0, 0.588235, 0.133333, 1) - -[resource] -code = "shader_type spatial; -uniform vec4 ColorParameter : source_color = vec4(0.000000, 0.588235, 0.133333, 1.000000); - - - -void fragment() { -// ColorParameter:2 - vec4 n_out2p0 = ColorParameter; - - -// Output:0 - ALBEDO = vec3(n_out2p0.xyz); - - -} -" -graph_offset = Vector2(-264.241, 71.7383) -nodes/fragment/2/node = SubResource("VisualShaderNodeColorParameter_fmfod") -nodes/fragment/2/position = Vector2(-29.888, 299) -nodes/fragment/connections = PackedInt32Array(2, 0, 0, 0) diff --git a/shader/debug2.tres b/shader/debug2.tres deleted file mode 100644 index d57b728..0000000 --- a/shader/debug2.tres +++ /dev/null @@ -1,28 +0,0 @@ -[gd_resource type="VisualShader" load_steps=2 format=3 uid="uid://v3mxp45i58ws"] - -[sub_resource type="VisualShaderNodeColorParameter" id="VisualShaderNodeColorParameter_k6e5s"] -parameter_name = "ColorParameter" -default_value_enabled = true -default_value = Color(0.8, 0.0470588, 0.0941176, 1) - -[resource] -code = "shader_type spatial; -uniform vec4 ColorParameter : source_color = vec4(0.800000, 0.047059, 0.094118, 1.000000); - - - -void fragment() { -// ColorParameter:2 - vec4 n_out2p0 = ColorParameter; - - -// Output:0 - ALBEDO = vec3(n_out2p0.xyz); - - -} -" -graph_offset = Vector2(-257.485, 76.9995) -nodes/fragment/2/node = SubResource("VisualShaderNodeColorParameter_k6e5s") -nodes/fragment/2/position = Vector2(-2, 329) -nodes/fragment/connections = PackedInt32Array(2, 0, 0, 0) diff --git a/src/player.cs b/src/player.cs index 08c62f2..0169064 100644 --- a/src/player.cs +++ b/src/player.cs @@ -1,17 +1,17 @@ using Godot; -using System; public partial class player : CharacterBody3D { - [Export] float Speed = 5.0f; - [Export] float JumpVelocity = 5f; + [Export] float speed = 5.0f; + [Export] float jumpVelocity = 5f; [Export] float gravity = 14f; [Export(PropertyHint.Range, "0.1,1.0")] float mouseSensitivity = 0.3f; [Export(PropertyHint.Range, "-90,0,1")] float minMousePitch = -90f; - [Export(PropertyHint.Range, "0,90,1")] float maxMousePitch = 50f; + [Export(PropertyHint.Range, "0,90,1")] float maxMousePitch = 90f; public override void _Process(double delta) { + //uncapturing the mouse disables player movement but still simulates gravity if (Input.IsActionJustPressed("uncapture_mouse")) Input.MouseMode = Input.MouseModeEnum.Visible; if (Input.IsMouseButtonPressed(MouseButton.Left)) Input.MouseMode = Input.MouseModeEnum.Captured; } @@ -20,25 +20,26 @@ public partial class player : CharacterBody3D Vector3 velocity = Velocity; if (!IsOnFloor()) - velocity.y -= gravity * (float)delta; + velocity.y -= gravity * (float)delta; //characterbodys don't have physic simulations by default like rigidbody if (Input.IsActionJustPressed("move_jump") && IsOnFloor() && Input.MouseMode == Input.MouseModeEnum.Captured) - velocity.y = JumpVelocity; + velocity.y = jumpVelocity; Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward"); - Vector3 direction = new Vector3(inputDir.x, 0, inputDir.y).Rotated(Vector3.Up, GetNode("camera_center").Rotation.y).Normalized(); + Vector3 direction = new Vector3(inputDir.x, 0, inputDir.y).Rotated(Vector3.Up, GetNode("camera_center").Rotation.y).Normalized(); //rotates the input direction with camera rotation if (direction != Vector3.Zero) { - velocity.x = direction.x * Speed; - velocity.z = direction.z * Speed; + velocity.x = direction.x * speed; + velocity.z = direction.z * speed; + //Rotating the body mesh to movement Vector3 bodyRotation = GetNode("collision/body").Rotation; - bodyRotation.y = Mathf.LerpAngle(bodyRotation.y,Mathf.Atan2(-direction.x, -direction.z), (float)delta * Speed); + bodyRotation.y = Mathf.LerpAngle(bodyRotation.y,Mathf.Atan2(-direction.x, -direction.z), (float)delta * speed); GetNode("collision/body").Rotation = bodyRotation; } else { - velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed); - velocity.z = Mathf.MoveToward(Velocity.z, 0, Speed); + velocity.x = Mathf.MoveToward(Velocity.x, 0, speed); + velocity.z = Mathf.MoveToward(Velocity.z, 0, speed); } Velocity = velocity; MoveAndSlide(); @@ -50,7 +51,7 @@ public partial class player : CharacterBody3D Vector3 camRot = GetNode("camera_center").RotationDegrees; camRot.y -= mouseMotion.Relative.x * mouseSensitivity; camRot.x -= mouseMotion.Relative.y * mouseSensitivity; - camRot.x = Mathf.Clamp(camRot.x, minMousePitch, maxMousePitch); + camRot.x = Mathf.Clamp(camRot.x, minMousePitch, maxMousePitch); //prevents camera from going endlessly around the player GetNode("camera_center").RotationDegrees = camRot; } } diff --git a/src/essential.cs b/src/window.cs similarity index 93% rename from src/essential.cs rename to src/window.cs index 6ef7919..1355609 100644 --- a/src/essential.cs +++ b/src/window.cs @@ -1,7 +1,7 @@ using Godot; using System; -public partial class essential : Node +public partial class window : Node { public override void _Ready() { diff --git a/test 3d project.csproj.old b/test 3d project.csproj.old deleted file mode 100644 index 9e1f738..0000000 --- a/test 3d project.csproj.old +++ /dev/null @@ -1,7 +0,0 @@ - - - net6.0 - true - test3dproject - - \ No newline at end of file