This commit is contained in:
2022-12-05 19:12:17 +01:00
commit 0afe0c4cbd
20 changed files with 354 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><g transform="translate(32 32)"><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99z" fill="#363d52"/><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99zm0 4h96c6.64 0 12 5.35 12 11.99v95.98c0 6.64-5.35 11.99-12 11.99h-96c-6.64 0-12-5.35-12-11.99v-95.98c0-6.64 5.36-11.99 12-11.99z" fill-opacity=".4"/></g><g stroke-width="9.92746" transform="matrix(.10073078 0 0 .10073078 12.425923 2.256365)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 919.24059 771.67186)"/><path d="m0 0v-47.514-6.035-5.492c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325c5.09692 6.4164715 9.92323 13.494208 13.621 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.4426579-6.973692 9.2079702-13.9828876 13.621-19.449z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 104.69892 525.90697)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.066.067c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 784.07144 817.24284)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 389.21484 625.67104)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 367.36686 631.05679)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 511.99336 724.73954)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 634.78706 625.67104)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 656.64056 631.05679)"/></g></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

39
icon.svg.import Normal file
View File

@@ -0,0 +1,39 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://defv3b6muei8w"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
path.etc2="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"
metadata={
"imported_formats": ["s3tc", "etc2"],
"vram_texture": true
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex", "res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

75
project.godot Normal file
View File

@@ -0,0 +1,75 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="test 3d project"
run/main_scene="res://scenes/main.tscn"
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
boot_splash/show_image=false
config/icon="res://icon.svg"
[autoload]
Essential="*res://src/essential.cs"
[display]
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
[dotnet]
project/assembly_name="test 3d project"
[input]
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)
]
}
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)
]
}
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)
]
}
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)
]
}
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,"unicode":0,"echo":false,"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)
]
}
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":false,"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)
]
}
[rendering]
anti_aliasing/quality/msaa_3d=2
anti_aliasing/quality/screen_space_aa=1

73
scenes/main.tscn Normal file
View File

@@ -0,0 +1,73 @@
[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"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_rubfc"]
ground_bottom_color = Color(0.87451, 0.952941, 1, 1)
ground_horizon_color = Color(0.631373, 0.654902, 0.713726, 1)
[sub_resource type="Sky" id="Sky_0i1vm"]
sky_material = SubResource("ProceduralSkyMaterial_rubfc")
[sub_resource type="Environment" id="Environment_3olxv"]
background_mode = 2
background_energy_multiplier = 0.14
sky = SubResource("Sky_0i1vm")
tonemap_mode = 1
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)
[sub_resource type="PlaneMesh" id="PlaneMesh_p3q8d"]
[sub_resource type="BoxShape3D" id="BoxShape3D_pxtb0"]
size = Vector3(1.994, 0.048, 2)
[sub_resource type="BoxMesh" id="BoxMesh_865hq"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1tea2"]
[node name="main" type="WorldEnvironment"]
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)
shape = SubResource("BoxShape3D_bxkt8")
[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"]
mesh = SubResource("PlaneMesh_p3q8d")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="ground"]
shape = SubResource("BoxShape3D_pxtb0")
[node name="cube" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.90701, 0.504965, -3.73153)
[node name="MeshInstance3D" type="MeshInstance3D" parent="cube"]
mesh = SubResource("BoxMesh_865hq")
[node name="CollisionShape3D" type="CollisionShape3D" parent="cube"]
shape = SubResource("BoxShape3D_1tea2")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.994703, -0.00611287, -0.102607, 0.101106, 0.238088, 0.965967, 0.0185247, -0.971224, 0.237445, 0, 0, 5.34355)
shadow_enabled = true
[node name="player" parent="." instance=ExtResource("1_1hi18")]

37
scenes/player.tscn Normal file
View File

@@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=3 uid="uid://b2ncexsbkd2ca"]
[ext_resource type="Script" path="res://src/player.cs" id="1_sqkid"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_4c62m"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bfc1o"]
[sub_resource type="SeparationRayShape3D" id="SeparationRayShape3D_31c1r"]
[node name="player" type="CharacterBody3D"]
script = ExtResource("1_sqkid")
[node name="mesh" type="MeshInstance3D" parent="."]
transform = Transform3D(0.999994, 0, 0.00349065, 0, 1.2, 0, -0.00349065, 0, 0.999994, 0, 1.2, 0)
mesh = SubResource("CapsuleMesh_4c62m")
skeleton = NodePath("")
[node name="collision" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1.2, 0, 0, 0, 1, 0, 1.2, 0)
shape = SubResource("CapsuleShape3D_bfc1o")
[node name="raycast" type="RayCast3D" parent="."]
transform = Transform3D(0.999965, 0.00425433, -0.00718195, -0.00722324, 0.00977106, -0.999926, -0.00418384, 0.999943, 0.00980145, 0.0215459, 1.13283, -1.47514)
target_position = Vector3(0, 1, 0)
[node name="camera_center" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 1.2, 0)
[node name="spring_arm" type="SpringArm3D" parent="camera_center"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, -5.96046e-08, 1, 0, 0, -0.5)
shape = SubResource("SeparationRayShape3D_31c1r")
spring_length = 6.0
[node name="camera" type="Camera3D" parent="camera_center/spring_arm"]
transform = Transform3D(1, 1.54914e-09, -6.87955e-10, -1.62981e-09, 0.990268, -0.139173, 4.65661e-10, 0.139173, 0.990269, 0, 0.0182246, 6.09616)
current = true

19
src/essential.cs Normal file
View File

@@ -0,0 +1,19 @@
using Godot;
using System;
public partial class essential : Node
{
public override void _Ready()
{
}
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);
}
}
}

80
src/player.cs Normal file
View File

@@ -0,0 +1,80 @@
using Godot;
using System;
using System.Diagnostics;
public partial class player : CharacterBody3D
{
public const float Speed = 5.0f;
public const float JumpVelocity = 4.5f;
public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
[Export (PropertyHint.Range, "0.1,1.0")] float mouseSensitivity = 0.3f;
[Export (PropertyHint.Range, "-90,0,1")] float minCamPitch = -90f;
[Export (PropertyHint.Range, "0,90,1")] float maxCamPitch = 90f;
public Marker3D cameraCenter;
public Camera3D camera;
public Vector3 camPosition;
public Vector3 playerResetPosition;
public override void _Ready()
{
cameraCenter = GetNode<Marker3D>("camera_center");
camera = GetNode<Camera3D>("camera_center/spring_arm/camera");
mouseSensitivity = mouseSensitivity * 0.005f;
Input.MouseMode = Input.MouseModeEnum.Captured;
}
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("uncapture_mouse")) Input.MouseMode = Input.MouseModeEnum.Visible;
if (Input.IsMouseButtonPressed(MouseButton.Left)) Input.MouseMode = Input.MouseModeEnum.Captured;//has to be disabled when the game has a pause menu
if (Input.IsActionJustPressed("move_forward"))
{
playerResetPosition = Rotation;
camPosition = cameraCenter.Rotation;
playerResetPosition.y = camPosition.y;
Rotation = playerResetPosition / 2;
Vector3 cameraResetPosition = cameraCenter.Rotation;
cameraCenter.Rotation = new Vector3 (cameraResetPosition.x,0,0); //resetpositions doesnt work because of fucking radians delete them fucking idiots
}
}
public override void _PhysicsProcess(double delta)
{
Vector3 velocity = Velocity;
if (!IsOnFloor())
velocity.y -= gravity * (float)delta;
if (Input.IsActionJustPressed("move_jump") && IsOnFloor())
velocity.y = JumpVelocity;
Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward");
Vector3 direction = (Transform.basis * new Vector3(inputDir.x, 0, inputDir.y)).Normalized();
if (direction != Vector3.Zero)
{
velocity.x = direction.x * Speed;
velocity.z = direction.z * Speed;
}
else
{
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)
{
if(@event is InputEventMouseMotion motionEvent && Input.MouseMode == Input.MouseModeEnum.Captured)
{
Vector3 generalRot = Rotation;
if (Input.IsActionPressed("move_forward")) generalRot.y -= motionEvent.Relative.x * mouseSensitivity;
Rotation = generalRot;
generalRot = cameraCenter.Rotation;
if (!Input.IsActionPressed("move_forward")) generalRot.y -= motionEvent.Relative.x * mouseSensitivity;
generalRot.x -= motionEvent.Relative.y * mouseSensitivity;
generalRot.x = Mathf.Clamp(generalRot.x, minCamPitch, maxCamPitch);
cameraCenter.Rotation = generalRot;
generalRot = cameraCenter.Rotation;
}
}
}

7
test 3d project.csproj Normal file
View File

@@ -0,0 +1,7 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.6">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>test3dproject</RootNamespace>
</PropertyGroup>
</Project>

19
test 3d project.sln Normal file
View File

@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test 3d project", "test 3d project.csproj", "{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
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
EndGlobalSection
EndGlobal