Vivi movement demo
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Normalize EOL for all files that Git considers text files.
|
||||||
|
* text=auto eol=lf
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -2,6 +2,9 @@
|
|||||||
# Godot 4+ specific ignores
|
# Godot 4+ specific ignores
|
||||||
.godot/
|
.godot/
|
||||||
|
|
||||||
|
# User-defined output folder
|
||||||
|
Output/
|
||||||
|
|
||||||
# Godot-specific ignores
|
# Godot-specific ignores
|
||||||
.import/
|
.import/
|
||||||
export.cfg
|
export.cfg
|
||||||
@@ -414,4 +417,3 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
|
||||||
|
|||||||
456
Models/vivi1.gltf
Normal file
456
Models/vivi1.gltf
Normal file
File diff suppressed because one or more lines are too long
32
Models/vivi1.gltf.import
Normal file
32
Models/vivi1.gltf.import
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://d20uxkpid4ynd"
|
||||||
|
path="res://.godot/imported/vivi1.gltf-bf803b8b19d92c48e740c5e4c4f22b01.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Models/vivi1.gltf"
|
||||||
|
dest_files=["res://.godot/imported/vivi1.gltf-bf803b8b19d92c48e740c5e4c4f22b01.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type="Node3D"
|
||||||
|
nodes/root_name="Scene Root"
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
import_script/path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
BIN
Models/vivi1_texture000.png
Normal file
BIN
Models/vivi1_texture000.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
36
Models/vivi1_texture000.png.import
Normal file
36
Models/vivi1_texture000.png.import
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cyqtuo5xg2v4o"
|
||||||
|
path.s3tc="res://.godot/imported/vivi1_texture000.png-b1b190d32b89ff1d5ea62a51fdb5f911.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
generator_parameters={}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Models/vivi1_texture000.png"
|
||||||
|
dest_files=["res://.godot/imported/vivi1_texture000.png-b1b190d32b89ff1d5ea62a51fdb5f911.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
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
|
||||||
BIN
Models/vivi1_texture001.png
Normal file
BIN
Models/vivi1_texture001.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
36
Models/vivi1_texture001.png.import
Normal file
36
Models/vivi1_texture001.png.import
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c0k08k4s2br84"
|
||||||
|
path.s3tc="res://.godot/imported/vivi1_texture001.png-1249f2b02589b735df5dc94c8c1c8710.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
generator_parameters={}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Models/vivi1_texture001.png"
|
||||||
|
dest_files=["res://.godot/imported/vivi1_texture001.png-1249f2b02589b735df5dc94c8c1c8710.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
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
|
||||||
BIN
Models/vivi1_texture002.png
Normal file
BIN
Models/vivi1_texture002.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
36
Models/vivi1_texture002.png.import
Normal file
36
Models/vivi1_texture002.png.import
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://0ooav1r441ar"
|
||||||
|
path.s3tc="res://.godot/imported/vivi1_texture002.png-3ec172687d79ff5655f4a4827f286ade.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
generator_parameters={}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Models/vivi1_texture002.png"
|
||||||
|
dest_files=["res://.godot/imported/vivi1_texture002.png-3ec172687d79ff5655f4a4827f286ade.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
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
|
||||||
BIN
Models/vivi1_texture003.png
Normal file
BIN
Models/vivi1_texture003.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
36
Models/vivi1_texture003.png.import
Normal file
36
Models/vivi1_texture003.png.import
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cad44uusgcjpu"
|
||||||
|
path.s3tc="res://.godot/imported/vivi1_texture003.png-b0c3c213d4231a37671a035c5e99577a.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
generator_parameters={}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Models/vivi1_texture003.png"
|
||||||
|
dest_files=["res://.godot/imported/vivi1_texture003.png-b0c3c213d4231a37671a035c5e99577a.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
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
|
||||||
6
Sandbox.csproj
Normal file
6
Sandbox.csproj
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.0.3">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
19
Sandbox.sln
Normal file
19
Sandbox.sln
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox.csproj", "{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}"
|
||||||
|
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
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
|
{5DAE2CF7-2349-4F8C-833E-1C0296A1B68A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
90
Scenes/Main.tscn
Normal file
90
Scenes/Main.tscn
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
[gd_scene load_steps=10 format=3 uid="uid://oq32v4vt173t"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d20uxkpid4ynd" path="res://Models/vivi1.gltf" id="1_mqt2m"]
|
||||||
|
[ext_resource type="Script" path="res://Scripts/CharacterBody3D.cs" id="1_ry77d"]
|
||||||
|
[ext_resource type="Script" path="res://Scenes/CameraSystem.cs" id="3_5ecw2"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_8verc"]
|
||||||
|
size = Vector3(100, 2, 100)
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_0jrjy"]
|
||||||
|
size = Vector3(100, 2, 100)
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_v20i5"]
|
||||||
|
radius = 0.3345
|
||||||
|
height = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8y7we"]
|
||||||
|
albedo_color = Color(0.937255, 0, 0.298039, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vn8ij"]
|
||||||
|
albedo_color = Color(0.509804, 0.584314, 1, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ultw4"]
|
||||||
|
albedo_color = Color(1, 1, 0, 1)
|
||||||
|
|
||||||
|
[node name="Main" type="Node"]
|
||||||
|
|
||||||
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.06471, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||||
|
shape = SubResource("BoxShape3D_8verc")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
|
||||||
|
mesh = SubResource("BoxMesh_0jrjy")
|
||||||
|
|
||||||
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.770914, 0.63694, 0, -0.63694, 0.770914, 0, 19.7871, 33.6204)
|
||||||
|
|
||||||
|
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||||
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, -0.242191, 0)
|
||||||
|
collision_layer = 2
|
||||||
|
script = ExtResource("1_ry77d")
|
||||||
|
_sensitivityHorizontal = 0.01
|
||||||
|
_sensitivityVertical = 0.01
|
||||||
|
|
||||||
|
[node name="Pivot" type="Node3D" parent="CharacterBody3D"]
|
||||||
|
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 0, 0)
|
||||||
|
|
||||||
|
[node name="vivi1" parent="CharacterBody3D/Pivot" instance=ExtResource("1_mqt2m")]
|
||||||
|
transform = Transform3D(-0.01, 0, -8.74228e-10, 0, 0.01, 0, 8.74228e-10, 0, -0.01, 0, 0.20569, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"]
|
||||||
|
transform = Transform3D(1, 0, 7.10543e-15, 0, 1, 0, -7.10543e-15, 0, 1, 0, 0.690513, 0)
|
||||||
|
shape = SubResource("CapsuleShape3D_v20i5")
|
||||||
|
|
||||||
|
[node name="Node3D" type="Node3D" parent="CharacterBody3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.495499, 0)
|
||||||
|
|
||||||
|
[node name="CameraMount" type="SpringArm3D" parent="CharacterBody3D"]
|
||||||
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 1.04459e-07, 1.07272, -1.19487)
|
||||||
|
spring_length = 2.0
|
||||||
|
margin = 0.2
|
||||||
|
script = ExtResource("3_5ecw2")
|
||||||
|
_sensitivityHorizontal = 0.03
|
||||||
|
_sensitivityVertical = 0.03
|
||||||
|
|
||||||
|
[node name="Camera3D" type="Camera3D" parent="CharacterBody3D/CameraMount"]
|
||||||
|
current = true
|
||||||
|
far = 54.29
|
||||||
|
|
||||||
|
[node name="Boxes" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="CSGBox3D" type="CSGBox3D" parent="Boxes"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.64941, 0.331903, -5.41311)
|
||||||
|
material_override = SubResource("StandardMaterial3D_8y7we")
|
||||||
|
use_collision = true
|
||||||
|
size = Vector3(2.97826, 5.85842, 2.94616)
|
||||||
|
|
||||||
|
[node name="CSGBox3D2" type="CSGBox3D" parent="Boxes"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.71382, 0.35579, -10.8262)
|
||||||
|
material_override = SubResource("StandardMaterial3D_vn8ij")
|
||||||
|
use_collision = true
|
||||||
|
size = Vector3(1, 1, 4.24746)
|
||||||
|
|
||||||
|
[node name="CSGBox3D3" type="CSGBox3D" parent="Boxes"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.54678, 0.383205, 4.07192)
|
||||||
|
material_override = SubResource("StandardMaterial3D_ultw4")
|
||||||
|
use_collision = true
|
||||||
|
size = Vector3(15.0266, 4.74018, 1)
|
||||||
50
Scripts/CameraSystem.cs
Normal file
50
Scripts/CameraSystem.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class CameraSystem : SpringArm3D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityHorizontal = 0.05f;
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityVertical = 0.05f;
|
||||||
|
[Export]
|
||||||
|
private float _joystickDeadZone = 0.5f;
|
||||||
|
|
||||||
|
private Node3D _pivot;
|
||||||
|
private CharacterBody3D _characterBody;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_pivot = GetNode<Node3D>("/root/Main/CharacterBody3D/Pivot");
|
||||||
|
_characterBody = GetNode<CharacterBody3D>("/root/Main/CharacterBody3D");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
var joyRightX = Input.GetJoyAxis(0, JoyAxis.RightX);
|
||||||
|
var joyRightY = Input.GetJoyAxis(0, JoyAxis.RightY);
|
||||||
|
|
||||||
|
if (Mathf.Abs(joyRightX) > _joystickDeadZone)
|
||||||
|
{
|
||||||
|
var rotateAmount = joyRightX * _sensitivityHorizontal;
|
||||||
|
_characterBody.RotateY(-rotateAmount);
|
||||||
|
_pivot.RotateY(rotateAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Mathf.Abs(joyRightY) > _joystickDeadZone)
|
||||||
|
{
|
||||||
|
RotateX(joyRightY * _sensitivityVertical);
|
||||||
|
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (@event is InputEventMouseMotion mouseMotion)
|
||||||
|
{
|
||||||
|
_characterBody.RotateY(Mathf.DegToRad(-mouseMotion.Relative.X * _sensitivityHorizontal));
|
||||||
|
_pivot.RotateY(Mathf.DegToRad(mouseMotion.Relative.X * _sensitivityHorizontal));
|
||||||
|
RotateX(Mathf.DegToRad(mouseMotion.Relative.Y * _sensitivityVertical));
|
||||||
|
Rotation = new Vector3(Mathf.Clamp(Rotation.X, -0.7f, 0.7f), Rotation.Y, Rotation.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
Scripts/CharacterBody3D.cs
Normal file
66
Scripts/CharacterBody3D.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
public partial class CharacterBody3D : Godot.CharacterBody3D
|
||||||
|
{
|
||||||
|
public const float Speed = 5.0f;
|
||||||
|
public const float JumpVelocity = 4.5f;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityHorizontal = 0.05f;
|
||||||
|
[Export]
|
||||||
|
private float _sensitivityVertical = 0.05f;
|
||||||
|
[Export]
|
||||||
|
private float _joystickDeadZone = 0.5f;
|
||||||
|
|
||||||
|
private Node3D _cameraMount;
|
||||||
|
private Node3D _pivot;
|
||||||
|
|
||||||
|
// Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||||
|
public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
_cameraMount = GetNode<Node3D>("/root/Main/CharacterBody3D/CameraMount");
|
||||||
|
_pivot = GetNode<Node3D>("/root/Main/CharacterBody3D/Pivot");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
{
|
||||||
|
if (Input.IsActionJustPressed("quit"))
|
||||||
|
GetTree().Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _PhysicsProcess(double delta)
|
||||||
|
{
|
||||||
|
Vector3 velocity = Velocity;
|
||||||
|
|
||||||
|
// Add the gravity.
|
||||||
|
if (!IsOnFloor())
|
||||||
|
velocity.Y -= gravity * (float)delta;
|
||||||
|
|
||||||
|
// Handle Jump.
|
||||||
|
if (Input.IsActionJustPressed("jump") && IsOnFloor())
|
||||||
|
velocity.Y = JumpVelocity;
|
||||||
|
|
||||||
|
// Get the input direction and handle the movement/deceleration.
|
||||||
|
// As good practice, you should replace UI actions with custom gameplay actions.
|
||||||
|
Vector2 inputDir = Input.GetVector("right", "left", "back", "forward");
|
||||||
|
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;
|
||||||
|
direction = direction.Normalized();
|
||||||
|
GetNode<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
|
||||||
|
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, Speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
Velocity = velocity;
|
||||||
|
MoveAndSlide();
|
||||||
|
}
|
||||||
|
}
|
||||||
74
project.godot
Normal file
74
project.godot
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
; 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="Sandbox"
|
||||||
|
run/main_scene="res://Scenes/Main.tscn"
|
||||||
|
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
||||||
|
|
||||||
|
[dotnet]
|
||||||
|
|
||||||
|
project/assembly_name="Sandbox"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
forward={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
back={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
jump={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
quit={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
joyrightX={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
joyrightY={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user