32 Commits
1.0 ... master

Author SHA1 Message Date
Yannik
b76342b8e6 Merge pull request #1 from JaN0h4ck/master 2024-03-21 10:07:35 +01:00
JaN0h4ck
72434b2480 Move GetNode calls to _Ready function 2024-03-21 09:28:53 +01:00
JaN0h4ck
8dbf6de4ea regenerate solution 2024-03-21 09:12:59 +01:00
JaN0h4ck
ce8f172d41 upgrade to godot 4.2 2024-03-21 09:08:30 +01:00
Yannik
b398d66fba Update readme.md 2024-02-25 15:43:43 +01:00
Yannik
8a87fb2ac0 lol doesnt work in small projects i guess 2023-05-03 22:38:58 +02:00
Yannik
3d305f4188 Create FUNDING.yml 2023-05-03 22:37:51 +02:00
ab3193c1f9 merge error 2023-03-01 19:06:04 +01:00
849abfdaf8 updated to godot 4.0 stable 2023-03-01 19:03:00 +01:00
Yannik
dd2ff50353 Update readme.md 2023-02-11 19:16:58 +01:00
Yannik
bc8a98ed3a Update readme.md 2023-02-11 19:16:42 +01:00
Yannik
8ed8edb03d Update readme.md 2023-01-28 19:59:28 +01:00
76fe7c74c2 major breaking update to godot 4 beta 16 2023-01-28 19:58:27 +01:00
bf27550b68 changed bg color thing, fixed alt enter fullscreen 2023-01-27 13:32:41 +01:00
10bd172d87 added attention request 2023-01-27 13:31:31 +01:00
88db434420 * delta 2023-01-27 09:54:22 +01:00
ca59509782 fixed bugs and cleaned code 2023-01-27 09:27:24 +01:00
db124a0776 added information alert 2023-01-27 09:25:41 +01:00
0e10367fc9 added controller support 2023-01-27 09:05:12 +01:00
6538bf5f7f reverted unknown change 2023-01-24 13:41:50 +01:00
17b2fd0817 big performance improvement 2023-01-24 13:41:25 +01:00
Yannik
983dbf978f Update readme.md 2023-01-13 23:13:01 +01:00
9697ab1216 jitterfix 0.5f faster 2023-01-06 16:53:45 +01:00
eee59dfa6a custom actual working jitterfix 2023-01-06 16:49:36 +01:00
3c0c6ce9c0 Merge branch 'master' of https://github.com/vaporvee/gd-mono-thirdpersoncontroller 2023-01-06 16:22:37 +01:00
61922a1b52 changed max fps like less physics simulations 2023-01-06 15:25:40 +01:00
Yannik
8897be3be1 Create LICENSE.md 2023-01-06 01:53:15 +01:00
af8f505fcc adjusted mousepitch clamp 2023-01-04 20:26:06 +01:00
4276bf20c5 Merge branch 'master' of https://github.com/vaporvee/gd-mono-thirdpersoncontroller 2023-01-04 20:24:55 +01:00
f4ec2bf05d renamed icon 2023-01-04 20:24:49 +01:00
Yannik
a41f5afb4f Update readme.md 2023-01-03 20:21:03 +01:00
Yannik
e5cfe86cb5 Update readme.md 2023-01-03 20:13:11 +01:00
11 changed files with 160 additions and 84 deletions

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 vaporvee
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,7 +1,9 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.10">
<Project Sdk="Godot.NET.Sdk/4.2.1">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>gd-mono-thirdpersoncontroller</RootNamespace>
<RootNamespace>gdmonothirdpersoncontroller</RootNamespace>
</PropertyGroup>
</Project>

View File

@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gd-mono-thirdpersoncontroller", "gd-mono-thirdpersoncontroller.csproj", "{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gd-mono-thirdpersoncontroller", "gd-mono-thirdpersoncontroller.csproj", "{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -9,11 +9,11 @@ Global
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

@@ -3,22 +3,22 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://nqd2l5xjbwh1"
path="res://.godot/imported/gd-mono-thirdpersoncontroller.png-1aea9d41ab1691227a784d4d60205324.ctex"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://gd-mono-thirdpersoncontroller.png"
dest_files=["res://.godot/imported/gd-mono-thirdpersoncontroller.png-1aea9d41ab1691227a784d4d60205324.ctex"]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View File

@@ -10,12 +10,12 @@ config_version=5
[application]
config/name="Godot Mono thirdperson controller"
config/name="Godot .NET thirdperson controller"
run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.0", "Forward Plus")
run/max_fps=144
config/features=PackedStringArray("4.2", "C#", "Forward Plus")
boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1)
boot_splash/show_image=false
config/icon="res://gd-mono-thirdpersoncontroller.png"
config/icon="res://icon.png"
[autoload]
@@ -32,53 +32,75 @@ project/assembly_name="gd-mono-thirdpersoncontroller"
[input]
move_jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
]
}
move_forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_backward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
]
}
move_jump={
gp_cam_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":-1.0,"script":null)
]
}
gp_cam_right={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":2,"axis_value":1.0,"script":null)
]
}
gp_cam_up={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":-1.0,"script":null)
]
}
gp_cam_down={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":3,"axis_value":1.0,"script":null)
]
}
fullscreen={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194342,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194342,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
uncapture_mouse={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194327,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194327,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[physics]
common/physics_ticks_per_second=144
3d/run_on_separate_thread=true
3d/default_gravity=12.0
[rendering]
lights_and_shadows/directional_shadow/size=6144
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=5
anti_aliasing/quality/msaa_3d=2
anti_aliasing/quality/screen_space_aa=1
environment/defaults/default_clear_color=Color(0, 0, 0, 1)
occlusion_culling/use_occlusion_culling=true

View File

@@ -1,3 +1,7 @@
# Godot Mono thirdperson controller
This is a working thirdperson controller made in the mono version of godot with C# <br>
Currently running in Godot 4 beta 10
# Godot 4.0 .NET thirdperson controller
This is a working thirdperson controller made in the .NET version of Godot 4.0 with C# <br>
<br>
[My Discord Server](https://discord.com/invite/EBdaTefpWy) <br><br>
Demo video: https://www.youtube.com/watch?v=qTzU90Vj3Nw<br>
<br>
<img width="200px" src="https://raw.githubusercontent.com/vaporvee/gd-mono-thirdpersoncontroller/master/icon.png">

View File

@@ -18,15 +18,15 @@ ssr_fade_out = 2.21914
[sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_0vf24"]
[sub_resource type="BoxMesh" id="BoxMesh_hmqcx"]
[sub_resource type="BoxShape3D" id="BoxShape3D_bxkt8"]
size = Vector3(1, 1, 1.24943)
size = Vector3(14, 7, 0.1)
[sub_resource type="BoxMesh" id="BoxMesh_hmqcx"]
[sub_resource type="PlaneMesh" id="PlaneMesh_p3q8d"]
[sub_resource type="BoxShape3D" id="BoxShape3D_pxtb0"]
size = Vector3(1.994, 0.048, 2)
size = Vector3(14, 0.1, 14)
[sub_resource type="BoxMesh" id="BoxMesh_865hq"]
@@ -37,24 +37,24 @@ environment = SubResource("Environment_3olxv")
camera_attributes = SubResource("CameraAttributesPhysical_0vf24")
[node name="wall" type="StaticBody3D" parent="."]
transform = Transform3D(3.18901, 0, 0, 0, 1.018, 0, 0, 0, 7, 0, 0, -0.704191)
[node name="MeshInstance3D" type="MeshInstance3D" parent="wall"]
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 0.02, 0.0452084, 2.24667, 1.0926)
mesh = SubResource("BoxMesh_hmqcx")
[node name="CollisionShape3D" type="CollisionShape3D" parent="wall"]
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 0.02, 0.04108, 2.19764, 1.09242)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.5, 7)
shape = SubResource("BoxShape3D_bxkt8")
[node name="MeshInstance3D" type="MeshInstance3D" parent="wall"]
transform = Transform3D(14, 0, 0, 0, 7, 0, 0, 0, 0.018, 0, 3.5, 7)
mesh = SubResource("BoxMesh_hmqcx")
[node name="ground" type="StaticBody3D" parent="."]
transform = Transform3D(7.781, 0, 0, 0, 1.018, 0, 0, 0, 7, 0, 0, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="ground"]
transform = Transform3D(7, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0)
mesh = SubResource("PlaneMesh_p3q8d")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0)
shape = SubResource("BoxShape3D_pxtb0")
[node name="cube" type="StaticBody3D" parent="."]

View File

@@ -3,6 +3,7 @@
[ext_resource type="Script" path="res://src/player.cs" id="1_sqkid"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bfc1o"]
height = 2.4
[sub_resource type="CapsuleMesh" id="CapsuleMesh_4c62m"]
@@ -22,11 +23,11 @@ font_size = 70
script = ExtResource("1_sqkid")
[node name="collision" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1.2, 0, 0, 0, 1, 0, 1.2, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2, 0)
shape = SubResource("CapsuleShape3D_bfc1o")
[node name="body" type="MeshInstance3D" parent="collision"]
transform = Transform3D(0.999994, 0, 0.00349065, 0, 1, 0, -0.00349065, 0, 0.999994, 0, 0, 0)
transform = Transform3D(0.999994, 0, 0.00349065, 0, 1.2, 0, -0.00349065, 0, 0.999994, 0, 0, 0)
mesh = SubResource("CapsuleMesh_4c62m")
skeleton = NodePath("")

View File

@@ -2,57 +2,83 @@ using Godot;
public partial class player : CharacterBody3D
{
public Vector3 direction;
public Vector2 gpCamVector;
public bool gamepadMode;
private Marker3D cameraCenter {get; set;}
private MeshInstance3D collisionBody {get; set;}
[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 = 90f;
[Export(PropertyHint.Range, "0.1,1.0")] float camSensitivity = 0.3f;
[Export(PropertyHint.Range, "-90,0,1")] float minCamPitch = -50f;
[Export(PropertyHint.Range, "0,90,1")] float maxCamPitch = 30f;
public override void _Ready() {
cameraCenter = GetNode<Marker3D>("camera_center");
collisionBody = GetNode<MeshInstance3D>("collision/body");
}
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;
//uncapturing the mouse disables PC 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;
/**body rotation is in regular process because it lags in physicsprocess and is more a animation anyway
maybe rotate extra collisions separately for invisible lag that may occur**/
if (direction != Vector3.Zero && Input.MouseMode == Input.MouseModeEnum.Captured | gamepadMode)
{
Vector3 bodyRotation = collisionBody.Rotation;
bodyRotation.Y = Mathf.LerpAngle(bodyRotation.Y,Mathf.Atan2(-direction.X, -direction.Z), (float)delta * speed);
collisionBody.Rotation = bodyRotation;
}
//camera gamepad part (needs constant movement so _Input event wouldn't work with this like mouseinput)
gpCamVector = Input.GetVector("gp_cam_left", "gp_cam_right", "gp_cam_up", "gp_cam_down");
if(gpCamVector != Vector2.Zero)
{
Vector3 camRot = cameraCenter.RotationDegrees;
camRot.Y -= gpCamVector.X * camSensitivity * (float)delta * 500;
camRot.X -= gpCamVector.Y * camSensitivity * (float)delta * 500;
camRot.X = Mathf.Clamp(camRot.X, minCamPitch, maxCamPitch); //prevents camera from going endlessly around the player
cameraCenter.RotationDegrees = camRot;
}
}
public override void _PhysicsProcess(double delta)
{
Vector3 velocity = Velocity;
if (!IsOnFloor())
velocity.y -= gravity * (float)delta; //characterbodys don't have physic simulations by default like rigidbody
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;
if (Input.IsActionJustPressed("move_jump") && IsOnFloor() && Input.MouseMode == Input.MouseModeEnum.Captured | gamepadMode)
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<Marker3D>("camera_center").Rotation.y).Normalized(); //rotates the input direction with camera rotation
if (direction != Vector3.Zero)
direction = new Vector3(inputDir.X, 0, inputDir.Y).Rotated(Vector3.Up, GetNode<Marker3D>("camera_center").Rotation.Y).Normalized(); //rotates the input direction with camera rotation
if (direction != Vector3.Zero && Input.MouseMode == Input.MouseModeEnum.Captured | gamepadMode)
{
velocity.x = direction.x * speed;
velocity.z = direction.z * speed;
//Rotating the body mesh to movement
Vector3 bodyRotation = GetNode<MeshInstance3D>("collision/body").Rotation;
bodyRotation.y = Mathf.LerpAngle(bodyRotation.y,Mathf.Atan2(-direction.x, -direction.z), (float)delta * speed);
GetNode<MeshInstance3D>("collision/body").Rotation = bodyRotation;
velocity.X = direction.X * speed * (float)delta * 60;
velocity.Z = direction.Z * speed * (float)delta * 60;
}
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();
}
}
public override void _Input(InputEvent @event)
{
gamepadMode = @event is InputEventJoypadButton | @event is InputEventJoypadMotion;
Vector3 camRot = cameraCenter.RotationDegrees;
if (@event is InputEventMouseMotion mouseMotion && Input.MouseMode == Input.MouseModeEnum.Captured)
{
Vector3 camRot = GetNode<Marker3D>("camera_center").RotationDegrees;
camRot.y -= mouseMotion.Relative.x * mouseSensitivity;
camRot.x -= mouseMotion.Relative.y * mouseSensitivity;
camRot.x = Mathf.Clamp(camRot.x, minMousePitch, maxMousePitch); //prevents camera from going endlessly around the player
GetNode<Marker3D>("camera_center").RotationDegrees = camRot;
camRot.Y -= mouseMotion.Relative.X * camSensitivity;
camRot.X -= mouseMotion.Relative.Y * camSensitivity;
}
camRot.X = Mathf.Clamp(camRot.X, minCamPitch, maxCamPitch); //prevents camera from going endlessly around the player
cameraCenter.RotationDegrees = camRot;
}
}

View File

@@ -4,17 +4,17 @@ using System;
public partial class window : Node
{
public override void _Ready()
{
ProjectSettings.SetSetting("physics/common/physics_ticks_per_second", Performance.GetMonitor(Performance.Monitor.TimeFps));
}
{
DisplayServer.WindowRequestAttention();
OS.Alert("Make sure that you either capture your mouse or play with a gamepad. Jump with space or bottom gamepad face button. Remove this message in window.cs - vaporvee.com","Information");
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("fullscreen"))
{
if (DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen)
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
else DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
}
}
if (Input.IsActionJustPressed("fullscreen"))
{
if (DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen)
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
else DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
}
}
}