Walking and Jumping

linux
Sascha 2024-02-11 15:17:18 +07:00
parent ef976286d2
commit 352cda40a2
17 changed files with 293 additions and 209 deletions

@ -1,9 +1,10 @@
<Project Sdk="Godot.NET.Sdk/4.3.0-dev.3">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>DRPGActionGame</RootNamespace>
<RootNamespace>3DRPGActionGame</RootNamespace>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

Binary file not shown.

@ -1,34 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://clgvdthd2g4kp"
path="res://.godot/imported/Grass.glb-04ac9d081482063301e14dd2cb1ae1c2.scn"
[deps]
source_file="res://Assets/Grass.glb"
dest_files=["res://.godot/imported/Grass.glb-04ac9d081482063301e14dd2cb1ae1c2.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
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
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bs8serpgyphv5"
path.s3tc="res://.godot/imported/texture_10.png-9e7da6fd69eb1f1b3eda3dca842245da.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Assets/texture_10.png"
dest_files=["res://.godot/imported/texture_10.png-9e7da6fd69eb1f1b3eda3dca842245da.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

@ -0,0 +1,46 @@
using Godot;
namespace DRPGActionGame.Player;
public partial class OldPlayer : CharacterBody3D
{
private const float SPEED = 5.0f;
private const float JUMP_VELOCITY = 4.5f;
// Get the gravity from the project settings to be synced with RigidBody nodes.
private float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
[Export] private AnimationPlayer animationPlayer;
public override void _PhysicsProcess(double delta)
{
Vector3 velocity = Velocity;
// Add the gravity.
if (!IsOnFloor())
velocity.Y -= gravity * (float)delta;
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
velocity.Y = JUMP_VELOCITY;
// 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("ui_left", "ui_right", "ui_up", "ui_down");
Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
animationPlayer.Play("Walk");
velocity.X = direction.X * SPEED;
velocity.Z = direction.Z * SPEED;
}
else {
animationPlayer.Play("Idle");
velocity.X = Mathf.MoveToward(Velocity.X, 0, SPEED);
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, SPEED);
}
Velocity = velocity;
MoveAndSlide();
}
}

@ -1,46 +1,50 @@
using DRPGActionGame.Player.States;
using Godot;
using static DRPGActionGame.Player.States.StateFactory.States;
namespace DRPGActionGame.Player;
public partial class Player : CharacterBody3D
{
private const float SPEED = 5.0f;
private const float JUMP_VELOCITY = 4.5f;
[Export] private AnimationTree? animationTree;
public const float SPEED = 5.0f;
public const float JUMP_VELOCITY = 9f; //4.5f;
public Vector3 Direction;
public AnimationNodeStateMachinePlayback? Playback;
// Get the gravity from the project settings to be synced with RigidBody nodes.
private State? state;
private float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
[Export] private AnimationPlayer animationPlayer;
public override void _Ready() {
if (animationTree != null)
Playback = (AnimationNodeStateMachinePlayback)animationTree.Get("parameters/playback");
else {
GD.PrintErr("No AnimationTree defined!");
}
ChangeState(Idle);
}
public override void _PhysicsProcess(double delta)
{
Vector3 velocity = Velocity;
if (!IsOnFloor()) velocity.Y -= gravity * (float)delta;
Velocity = velocity;
MoveAndSlide();
}
// Add the gravity.
if (!IsOnFloor())
velocity.Y -= gravity * (float)delta;
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
velocity.Y = JUMP_VELOCITY;
// 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("ui_left", "ui_right", "ui_up", "ui_down");
Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
animationPlayer.Play("Walk");
velocity.X = direction.X * SPEED;
velocity.Z = direction.Z * SPEED;
public void ChangeState(StateFactory.States newState) {
//Remove state if available
state?.ExitState();
//Add New State
state = new StateFactory().GetState(newState);
if (state != null) {
state.Setup(newState, Playback, this);
state.Name = newState.ToString();
AddChild(state);
}
else {
animationPlayer.Play("Idle");
velocity.X = Mathf.MoveToward(Velocity.X, 0, SPEED);
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, SPEED);
GD.PrintErr($"State {newState} not found!");
}
Velocity = velocity;
MoveAndSlide();
}
}

@ -1,57 +0,0 @@
using DRPGActionGame.Player.States;
using Godot;
using static DRPGActionGame.Player.States.StateFactory.States;
namespace DRPGActionGame.Player;
public partial class Player2 : CharacterBody3D
{
public const float SPEED = 5.0f;
public const float JUMP_VELOCITY = 9f; //4.5f;
public Vector3 Direction;
// Get the gravity from the project settings to be synced with RigidBody nodes.
private float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
// [Export] private AnimationPlayer animationPlayer;
[Export] private AnimationTree animationTree;
public AnimationNodeStateMachinePlayback Playback;
private StateFactory stateFactory;
private State state;
public override void _Ready() {
stateFactory = new();
Playback = (AnimationNodeStateMachinePlayback)animationTree.Get("parameters/playback");
ChangeState(Idle);
ChangeState(Move);
}
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 = JUMP_VELOCITY;
ChangeState(Jump);
}
// Get the input direction and handle the movement/deceleration.
Direction = new(Input.GetActionStrength("WalkLeft") - Input.GetActionStrength("WalkRight"), 0, Input.GetActionStrength("WalkUp") - Input.GetActionStrength("WalkDown"));
if (Direction != Vector3.Zero && state.ChangeState == Idle) ChangeState(Move);
Velocity = velocity;
MoveAndSlide();
}
public void ChangeState(StateFactory.States newState) {
//Remove state if available
state?.Exit();
//Add New State
state = new StateFactory().GetState(newState);
state.Setup(newState, Playback, this);
AddChild(state);
}
}

@ -1,6 +1,6 @@
[gd_scene load_steps=118 format=3 uid="uid://cbn878rbtj1a8"]
[gd_scene load_steps=127 format=3 uid="uid://cbn878rbtj1a8"]
[ext_resource type="Script" path="res://Player/Player2.cs" id="1_1dafw"]
[ext_resource type="Script" path="res://Player/Player.cs" id="1_ghhig"]
[ext_resource type="Texture2D" uid="uid://ds7yw5hcveax2" path="res://Assets/KayKit_Skeletons_1.0_FREE/characters/gltf/Skeleton_Minion_skeleton_texture.png" id="2_sjwvv"]
[ext_resource type="Script" path="res://Player/CameraController.cs" id="3_ckwbt"]
@ -69959,7 +69959,6 @@ _data = {
}
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_a6wip"]
height = 1.7
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_pr3um"]
animation = &"1H_Melee_Attack_Chop"
@ -69973,6 +69972,37 @@ animation = &"Jump_Full_Long"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_g231r"]
animation = &"Walking_A"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_2tjgj"]
xfade_time = 0.5
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_lf8wq"]
xfade_time = 0.5
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_w4exk"]
xfade_time = 0.1
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_dg7d1"]
xfade_time = 0.5
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_kaggd"]
xfade_time = 0.5
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_oi3vr"]
xfade_time = 0.5
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_7k5pd"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_gjrxj"]
xfade_time = 0.5
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_35ysj"]
xfade_time = 0.5
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_v1jjm"]
states/End/position = Vector2(856, 127)
states/Start/position = Vector2(285, 127)
@ -69984,11 +70014,11 @@ states/jump/node = SubResource("AnimationNodeAnimation_6gdft")
states/jump/position = Vector2(538, 213)
states/move/node = SubResource("AnimationNodeAnimation_g231r")
states/move/position = Vector2(538, 38)
transitions = ["idle", "move", SubResource("AnimationNodeStateMachineTransition_2tjgj"), "move", "idle", SubResource("AnimationNodeStateMachineTransition_lf8wq"), "idle", "jump", SubResource("AnimationNodeStateMachineTransition_w4exk"), "jump", "idle", SubResource("AnimationNodeStateMachineTransition_dg7d1"), "idle", "attack", SubResource("AnimationNodeStateMachineTransition_kaggd"), "attack", "idle", SubResource("AnimationNodeStateMachineTransition_oi3vr"), "Start", "idle", SubResource("AnimationNodeStateMachineTransition_7k5pd"), "move", "attack", SubResource("AnimationNodeStateMachineTransition_gjrxj"), "jump", "attack", SubResource("AnimationNodeStateMachineTransition_35ysj")]
graph_offset = Vector2(-64, -21)
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("animationTree")]
script = ExtResource("1_1dafw")
animationTree = NodePath("AnimationTree")
[node name="Player" type="CharacterBody3D"]
script = ExtResource("1_ghhig")
[node name="Skeleton_Minion" type="Node3D" parent="."]
@ -70000,21 +70030,21 @@ bones/0/parent = -1
bones/0/rest = Transform3D(1, 0, 2.38419e-07, 0, 1, 0, -2.38419e-07, 0, 1, 0, 0, 0)
bones/0/enabled = true
bones/0/position = Vector3(0, 0, 0)
bones/0/rotation = Quaternion(0, 1.1921e-07, 0, 1)
bones/0/rotation = Quaternion(0, 1.19209e-07, 0, 1)
bones/0/scale = Vector3(1, 1, 1)
bones/1/name = "hips"
bones/1/parent = 0
bones/1/rest = Transform3D(1, 0, -2.38419e-07, 0, 1, 0, 2.38419e-07, 0, 1, 0, 0.405663, 0)
bones/1/enabled = true
bones/1/position = Vector3(0, 0.405663, 0)
bones/1/rotation = Quaternion(0, -1.1921e-07, 0, 1)
bones/1/position = Vector3(0, 0.377108, 0)
bones/1/rotation = Quaternion(-1.11123e-10, 0.0431578, 2.57241e-09, 0.999068)
bones/1/scale = Vector3(1, 1, 1)
bones/2/name = "spine"
bones/2/parent = 1
bones/2/rest = Transform3D(1, 0, 1.42109e-14, 0, 1, 0, -1.42109e-14, 0, 1, 0, 0.191978, 0)
bones/2/enabled = true
bones/2/position = Vector3(0, 0.191978, 0)
bones/2/rotation = Quaternion(0, 7.10545e-15, 0, 1)
bones/2/rotation = Quaternion(0, 7.10543e-15, 0, 1)
bones/2/scale = Vector3(1, 1, 1)
bones/3/name = "chest"
bones/3/parent = 2
@ -70028,168 +70058,168 @@ bones/4/parent = 3
bones/4/rest = Transform3D(0.0572842, 0.998357, -4.47035e-07, -3.8743e-07, 4.76837e-07, 1, 0.998357, -0.0572842, 4.17232e-07, 0.212007, 0.134132, 8.40246e-08)
bones/4/enabled = true
bones/4/position = Vector3(0.212007, 0.134132, 8.40246e-08)
bones/4/rotation = Quaternion(-0.514121, -0.485468, -0.485468, 0.514122)
bones/4/rotation = Quaternion(-0.554765, -0.0574756, -0.638056, 0.530865)
bones/4/scale = Vector3(0.999999, 0.999999, 1)
bones/5/name = "lowerarm.l"
bones/5/parent = 4
bones/5/rest = Transform3D(0.993887, 0.110402, -1.19007e-07, -0.110402, 0.993887, 3.28831e-09, 1.18643e-07, 9.87044e-09, 1, -3.21966e-09, 0.241897, -1.19406e-07)
bones/5/enabled = true
bones/5/position = Vector3(-3.21966e-09, 0.241897, -1.19406e-07)
bones/5/rotation = Quaternion(1.64805e-09, -5.95036e-08, -0.0552856, 0.998471)
bones/5/rotation = Quaternion(1.38175e-08, -7.82148e-08, -0.51227, 0.858824)
bones/5/scale = Vector3(1, 1, 1)
bones/6/name = "wrist.l"
bones/6/parent = 5
bones/6/rest = Transform3D(0.998579, -0.0532972, -6.01854e-10, 0.0532972, 0.998579, 1.78776e-10, 5.9147e-10, -2.10599e-10, 1, 8.71929e-09, 0.260044, -1.50195e-10)
bones/6/enabled = true
bones/6/position = Vector3(8.71929e-09, 0.260044, -1.50195e-10)
bones/6/rotation = Quaternion(-9.73783e-11, -2.98437e-10, 0.0266581, 0.999645)
bones/6/rotation = Quaternion(-9.73784e-11, -2.98437e-10, 0.0266581, 0.999645)
bones/6/scale = Vector3(1, 1, 1)
bones/7/name = "hand.l"
bones/7/parent = 6
bones/7/rest = Transform3D(1, 1.09104e-05, 2.66204e-07, -1.09104e-05, 1, -2.40181e-09, -2.66204e-07, 2.39891e-09, 1, 9.08162e-13, 0.0738258, 2.22045e-16)
bones/7/enabled = true
bones/7/position = Vector3(9.08162e-13, 0.0738258, 2.22045e-16)
bones/7/rotation = Quaternion(1.20018e-09, 1.33102e-07, -5.4552e-06, 1)
bones/7/rotation = Quaternion(-0.32186, -0.334531, 0.150139, 0.872899)
bones/7/scale = Vector3(1, 1, 1)
bones/8/name = "handslot.l"
bones/8/parent = 7
bones/8/rest = Transform3D(-1.19209e-07, 1, -4.44089e-16, -1, -1.19209e-07, -4.55307e-09, -4.55307e-09, -2.22045e-16, 1, 8.34815e-10, 0.0961251, -0.0575001)
bones/8/enabled = true
bones/8/position = Vector3(8.34815e-10, 0.0961251, -0.0575001)
bones/8/rotation = Quaternion(1.60975e-09, 1.60975e-09, -0.707107, 0.707107)
bones/8/rotation = Quaternion(0.00053303, 0.000533019, -0.705148, 0.70906)
bones/8/scale = Vector3(1, 1, 1)
bones/9/name = "upperarm.r"
bones/9/parent = 3
bones/9/rest = Transform3D(0.0572842, -0.998357, 5.06639e-07, 5.66244e-07, 4.76837e-07, 1, -0.998357, -0.0572843, 4.76837e-07, -0.212007, 0.134132, 8.40246e-08)
bones/9/enabled = true
bones/9/position = Vector3(-0.212007, 0.134132, 8.40246e-08)
bones/9/rotation = Quaternion(-0.514121, 0.485468, 0.485468, 0.514122)
bones/9/rotation = Quaternion(-0.61316, 0.0777837, 0.613343, 0.491727)
bones/9/scale = Vector3(0.999999, 0.999999, 1)
bones/10/name = "lowerarm.r"
bones/10/parent = 9
bones/10/rest = Transform3D(0.993887, -0.110402, 1.19007e-07, 0.110402, 0.993887, 3.28831e-09, -1.18643e-07, 9.87044e-09, 1, -7.12186e-11, 0.241897, -1.19406e-07)
bones/10/enabled = true
bones/10/position = Vector3(-7.12186e-11, 0.241897, -1.19406e-07)
bones/10/rotation = Quaternion(1.64805e-09, 5.95036e-08, 0.0552856, 0.998471)
bones/10/rotation = Quaternion(1.53477e-08, 5.75064e-08, 0.534777, 0.844993)
bones/10/scale = Vector3(1, 1, 1)
bones/11/name = "wrist.r"
bones/11/parent = 10
bones/11/rest = Transform3D(0.998579, 0.0532972, 6.01854e-10, -0.0532972, 0.998579, 1.78776e-10, -5.9147e-10, -2.10599e-10, 1, -8.71838e-09, 0.260044, -1.50195e-10)
bones/11/enabled = true
bones/11/position = Vector3(-8.71838e-09, 0.260044, -1.50195e-10)
bones/11/rotation = Quaternion(-9.73783e-11, 2.98437e-10, -0.0266581, 0.999645)
bones/11/rotation = Quaternion(-9.73784e-11, 2.98437e-10, -0.0266581, 0.999645)
bones/11/scale = Vector3(1, 1, 1)
bones/12/name = "hand.r"
bones/12/parent = 11
bones/12/rest = Transform3D(1, -1.09104e-05, -1.78637e-07, 1.09104e-05, 1, -2.40084e-09, 1.78637e-07, 2.39889e-09, 1, 1.33227e-15, 0.0738258, 2.22045e-16)
bones/12/enabled = true
bones/12/position = Vector3(1.33227e-15, 0.0738258, 2.22045e-16)
bones/12/rotation = Quaternion(1.19993e-09, -8.93185e-08, 5.4552e-06, 1)
bones/12/rotation = Quaternion(-0.320654, 0.310578, -0.232181, 0.864184)
bones/12/scale = Vector3(1, 1, 1)
bones/13/name = "handslot.r"
bones/13/parent = 12
bones/13/rest = Transform3D(-1.19209e-07, -1, 4.44089e-16, 1, -1.19209e-07, -4.55301e-09, 4.55301e-09, -2.22045e-16, 1, -8.34815e-10, 0.0961251, -0.0575001)
bones/13/enabled = true
bones/13/position = Vector3(-8.34815e-10, 0.0961251, -0.0575001)
bones/13/rotation = Quaternion(1.60973e-09, -1.60973e-09, 0.707107, 0.707107)
bones/13/rotation = Quaternion(0.00171318, 0.00201788, 0.705327, 0.708878)
bones/13/scale = Vector3(1, 1, 1)
bones/14/name = "head"
bones/14/parent = 3
bones/14/rest = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.268797, 0)
bones/14/enabled = true
bones/14/position = Vector3(0, 0.268797, 0)
bones/14/rotation = Quaternion(0, 0, 0, 1)
bones/14/rotation = Quaternion(-5.80608e-11, -0.0313417, -1.88012e-09, 0.999509)
bones/14/scale = Vector3(1, 1, 1)
bones/15/name = "upperleg.l"
bones/15/parent = 1
bones/15/rest = Transform3D(1, -1.42215e-07, -2.65602e-08, -1.43052e-07, -0.999396, -0.0347412, -2.16035e-08, 0.0347411, -0.999398, 0.170945, 0.113587, 1.39233e-08)
bones/15/enabled = true
bones/15/position = Vector3(0.170945, 0.113587, 1.39233e-08)
bones/15/rotation = Quaternion(0.999849, -7.13275e-08, -1.20428e-08, 0.0173732)
bones/15/rotation = Quaternion(0.991298, 0.083233, 0.0773854, 0.066425)
bones/15/scale = Vector3(1, 1, 1)
bones/16/name = "lowerleg.l"
bones/16/parent = 15
bones/16/rest = Transform3D(1, 1.6129e-07, 1.20856e-07, -1.3212e-07, 0.977433, -0.211248, -1.52201e-07, 0.211248, 0.977433, 3.57982e-09, 0.227077, -6.13986e-09)
bones/16/enabled = true
bones/16/position = Vector3(3.57982e-09, 0.227077, -6.13986e-09)
bones/16/rotation = Quaternion(0.106225, 6.86527e-08, -7.377e-08, 0.994342)
bones/16/rotation = Quaternion(0.340561, 5.97817e-08, -2.42291e-07, 0.940223)
bones/16/scale = Vector3(1, 1, 1)
bones/17/name = "foot.l"
bones/17/parent = 16
bones/17/rest = Transform3D(1, 4.64335e-08, 6.01239e-08, -7.59277e-08, 0.585515, 0.810661, 2.4383e-09, -0.810662, 0.585514, 1.83222e-10, 0.149437, 9.66537e-10)
bones/17/enabled = true
bones/17/position = Vector3(1.83222e-10, 0.149437, 9.66537e-10)
bones/17/rotation = Quaternion(-0.455239, 1.61971e-08, -3.43569e-08, 0.890369)
bones/17/rotation = Quaternion(-0.592976, -0.20389, 0.0669989, 0.776092)
bones/17/scale = Vector3(1, 1, 0.999999)
bones/18/name = "toes.l"
bones/18/parent = 17
bones/18/rest = Transform3D(-1, 1.3329e-07, 6.94339e-08, 4.25341e-08, 0.694104, -0.719875, -1.44146e-07, -0.71987, -0.694109, -1.51142e-08, 0.16565, 5.17173e-09)
bones/18/enabled = true
bones/18/position = Vector3(-1.51142e-08, 0.16565, 5.17173e-09)
bones/18/rotation = Quaternion(4.77598e-08, 0.920355, -0.391084, 5.80155e-08)
bones/18/rotation = Quaternion(6.5496e-06, 0.920164, -0.391534, -1.42537e-06)
bones/18/scale = Vector3(1, 0.999997, 1)
bones/19/name = "upperleg.r"
bones/19/parent = 1
bones/19/rest = Transform3D(1, 1.49611e-07, -6.08626e-08, 1.47406e-07, -0.999396, -0.0347412, -6.60234e-08, 0.0347411, -0.999398, -0.170945, 0.113587, 1.39233e-08)
bones/19/enabled = true
bones/19/position = Vector3(-0.170945, 0.113587, 1.39233e-08)
bones/19/rotation = Quaternion(0.999849, 7.42654e-08, -3.17263e-08, 0.0173732)
bones/19/rotation = Quaternion(0.993556, -0.0321079, 0.0303238, 0.104389)
bones/19/scale = Vector3(1, 1, 1)
bones/20/name = "lowerleg.r"
bones/20/parent = 19
bones/20/rest = Transform3D(1, -1.6129e-07, -1.20856e-07, 1.3212e-07, 0.977433, -0.211248, 1.52201e-07, 0.211248, 0.977433, -3.57982e-09, 0.227077, -6.13986e-09)
bones/20/enabled = true
bones/20/position = Vector3(-3.57982e-09, 0.227077, -6.13986e-09)
bones/20/rotation = Quaternion(0.106225, -6.86527e-08, 7.377e-08, 0.994342)
bones/20/rotation = Quaternion(0.39091, -6.06774e-08, 2.73397e-07, 0.920429)
bones/20/scale = Vector3(1, 1, 1)
bones/21/name = "foot.r"
bones/21/parent = 20
bones/21/rest = Transform3D(1, -1.55132e-07, 2.93521e-07, -1.47115e-07, 0.585515, 0.810661, -2.97621e-07, -0.810662, 0.585514, -1.83221e-10, 0.149437, 9.66542e-10)
bones/21/enabled = true
bones/21/position = Vector3(-1.83221e-10, 0.149437, 9.66542e-10)
bones/21/rotation = Quaternion(-0.455239, 1.65983e-07, 2.25101e-09, 0.890369)
bones/21/rotation = Quaternion(-0.621446, 0.113307, -0.0188045, 0.774992)
bones/21/scale = Vector3(1, 1, 0.999999)
bones/22/name = "toes.r"
bones/22/parent = 21
bones/22/rest = Transform3D(-1, 8.95136e-08, 1.0214e-07, -1.1395e-08, 0.694104, -0.719875, -1.35334e-07, -0.71987, -0.694109, 2.13058e-10, 0.16565, 5.17174e-09)
bones/22/enabled = true
bones/22/position = Vector3(2.13058e-10, 0.16565, 5.17174e-09)
bones/22/rotation = Quaternion(2.12198e-08, 0.920355, -0.391084, 6.45059e-08)
bones/22/rotation = Quaternion(-8.93489e-05, 0.920222, -0.391398, 2.0291e-05)
bones/22/scale = Vector3(1, 0.999997, 1)
bones/23/name = "kneeIK.l"
bones/23/parent = 0
bones/23/rest = Transform3D(1, -2.59151e-07, -3.89414e-07, -3.89414e-07, 0, -1, 2.59151e-07, 1, 0, 0.170945, 0.29231, 0.575812)
bones/23/enabled = true
bones/23/position = Vector3(0.170945, 0.29231, 0.575812)
bones/23/rotation = Quaternion(0.707107, -2.29302e-07, -4.60549e-08, 0.707107)
bones/23/rotation = Quaternion(0.707107, -2.29302e-07, -4.60552e-08, 0.707107)
bones/23/scale = Vector3(1, 1, 1)
bones/24/name = "control-toe-roll.l"
bones/24/parent = 0
bones/24/rest = Transform3D(1, 1.99485e-07, -2.13163e-14, 2.13163e-14, 0, 1, 1.99485e-07, -1, 0, 0.170945, 0.0259903, 0.245789)
bones/24/enabled = true
bones/24/position = Vector3(0.170945, 0.0259903, 0.245789)
bones/24/rotation = Quaternion(-0.707107, -7.05286e-08, -7.05286e-08, 0.707107)
bones/24/position = Vector3(0.202182, 0.0259903, 0.205181)
bones/24/rotation = Quaternion(-0.707107, -7.05285e-08, -7.05285e-08, 0.707107)
bones/24/scale = Vector3(1, 1, 1)
bones/25/name = "control-heel-roll.l"
bones/25/parent = 24
bones/25/rest = Transform3D(-1, 4.66e-34, 1.42109e-14, -4.69932e-34, -1, -2.76642e-22, 1.42109e-14, -2.76642e-22, 1, 1.94581e-08, 0.362833, -2.42861e-15)
bones/25/enabled = true
bones/25/position = Vector3(1.94581e-08, 0.362833, -2.42861e-15)
bones/25/rotation = Quaternion(7.10545e-15, -1.38321e-22, 1, -2.33983e-34)
bones/25/rotation = Quaternion(9.65792e-09, 1.77955e-09, 0.985719, -0.168398)
bones/25/scale = Vector3(1, 1, 1)
bones/26/name = "control-foot-roll.l"
bones/26/parent = 25
bones/26/rest = Transform3D(-1, -2.70242e-08, -2.14593e-07, -1.35722e-07, -0.694106, 0.719873, -1.68404e-07, 0.719873, 0.694106, -1.11482e-08, 0.213436, -2.50942e-15)
bones/26/enabled = true
bones/26/position = Vector3(-1.11482e-08, 0.213436, -2.50942e-15)
bones/26/rotation = Quaternion(-1.04035e-07, 0.391084, 0.920355, -2.95261e-08)
bones/26/rotation = Quaternion(-1.04035e-07, 0.391084, 0.920355, -2.9526e-08)
bones/26/scale = Vector3(1, 1, 1)
bones/27/name = "heelIK.l"
bones/27/parent = 26
bones/27/rest = Transform3D(1, 1.74656e-07, -7.54001e-08, -6.69512e-08, 0.694106, 0.719873, 1.78066e-07, -0.719873, 0.694106, 8.58988e-09, 0.16565, -5.09137e-09)
bones/27/enabled = true
bones/27/position = Vector3(8.58988e-09, 0.16565, -5.09137e-09)
bones/27/rotation = Quaternion(-0.391084, -6.88502e-08, -6.56289e-08, 0.920355)
bones/27/rotation = Quaternion(-0.391084, -6.885e-08, -6.56288e-08, 0.920355)
bones/27/scale = Vector3(1, 1, 1)
bones/28/name = "IK-foot.l"
bones/28/parent = 26
@ -70203,28 +70233,28 @@ bones/29/parent = 25
bones/29/rest = Transform3D(1, 3.89339e-08, -1.3482e-16, -3.89339e-08, 1, -2.71393e-22, 1.3482e-16, 2.76642e-22, 1, -4.55695e-09, -7.95029e-10, -1.86265e-09)
bones/29/enabled = true
bones/29/position = Vector3(-4.55695e-09, -7.95029e-10, -1.86265e-09)
bones/29/rotation = Quaternion(1.37009e-22, -6.741e-17, -1.9467e-08, 1)
bones/29/rotation = Quaternion(1.37009e-22, -6.74098e-17, -1.94669e-08, 1)
bones/29/scale = Vector3(1, 1, 1)
bones/30/name = "kneeIK.r"
bones/30/parent = 0
bones/30/rest = Transform3D(1, -2.59151e-07, 1.50996e-07, 1.50996e-07, 0, -1, 2.59151e-07, 1, 0, -0.170945, 0.29231, 0.575812)
bones/30/enabled = true
bones/30/position = Vector3(-0.170945, 0.29231, 0.575812)
bones/30/rotation = Quaternion(0.707107, -3.82386e-08, 1.45009e-07, 0.707107)
bones/30/rotation = Quaternion(0.707107, -3.82385e-08, 1.45009e-07, 0.707107)
bones/30/scale = Vector3(1, 1, 1)
bones/31/name = "control-toe-roll.r"
bones/31/parent = 0
bones/31/rest = Transform3D(1, 1.99485e-07, -7.10543e-15, 7.10543e-15, 0, 1, 1.99485e-07, -1, 0, -0.170945, 0.0259903, 0.245789)
bones/31/enabled = true
bones/31/position = Vector3(-0.170945, 0.0259903, 0.245789)
bones/31/rotation = Quaternion(-0.707107, -7.05286e-08, -7.05286e-08, 0.707107)
bones/31/rotation = Quaternion(-0.707107, -7.05285e-08, -7.05285e-08, 0.707107)
bones/31/scale = Vector3(1, 1, 1)
bones/32/name = "control-heel-roll.r"
bones/32/parent = 31
bones/32/rest = Transform3D(-1, 4.66e-34, 1.42109e-14, -4.69932e-34, -1, -2.76642e-22, 1.42109e-14, -2.76642e-22, 1, 1.94581e-08, 0.362833, 2.42861e-15)
bones/32/enabled = true
bones/32/position = Vector3(1.94581e-08, 0.362833, 2.42861e-15)
bones/32/rotation = Quaternion(7.10545e-15, -1.38321e-22, 1, -2.33983e-34)
bones/32/rotation = Quaternion(-5.83589e-09, 6.43837e-10, 0.994809, 0.101756)
bones/32/scale = Vector3(1, 1, 1)
bones/33/name = "control-foot-roll.r"
bones/33/parent = 32
@ -70238,49 +70268,49 @@ bones/34/parent = 33
bones/34/rest = Transform3D(1, 1.74656e-07, -7.54001e-08, -6.69512e-08, 0.694106, 0.719873, 1.78066e-07, -0.719873, 0.694106, -6.31128e-09, 0.16565, 1.36608e-09)
bones/34/enabled = true
bones/34/position = Vector3(-6.31128e-09, 0.16565, 1.36608e-09)
bones/34/rotation = Quaternion(-0.391084, -6.88502e-08, -6.56289e-08, 0.920355)
bones/34/rotation = Quaternion(-0.391084, -6.885e-08, -6.56288e-08, 0.920355)
bones/34/scale = Vector3(1, 1, 1)
bones/35/name = "IK-foot.r"
bones/35/parent = 33
bones/35/rest = Transform3D(1, 8.88173e-16, 3.89414e-07, 8.88173e-16, -1, -1.21054e-21, 3.89414e-07, 1.55641e-21, -1, -2.12124e-08, 0.16565, 1.36608e-09)
bones/35/enabled = true
bones/35/position = Vector3(-2.12124e-08, 0.16565, 1.36608e-09)
bones/35/rotation = Quaternion(1, 4.44087e-16, 1.94707e-07, 6.91738e-22)
bones/35/rotation = Quaternion(1, 4.44086e-16, 1.94707e-07, 6.91739e-22)
bones/35/scale = Vector3(1, 1, 1)
bones/36/name = "IK-toe.r"
bones/36/parent = 32
bones/36/rest = Transform3D(1, 3.89338e-08, -1.3482e-16, -3.89338e-08, 1, -2.71392e-22, 1.3482e-16, 2.76642e-22, 1, -4.55695e-09, 7.95036e-10, -1.86265e-09)
bones/36/enabled = true
bones/36/position = Vector3(-4.55695e-09, 7.95036e-10, -1.86265e-09)
bones/36/rotation = Quaternion(1.37009e-22, -6.741e-17, -1.94669e-08, 1)
bones/36/rotation = Quaternion(1.37009e-22, -6.74099e-17, -1.94669e-08, 1)
bones/36/scale = Vector3(1, 1, 1)
bones/37/name = "elbowIK.l"
bones/37/parent = 0
bones/37/rest = Transform3D(1, 2.05896e-07, -2.84217e-14, 2.84217e-14, 0, 1, 2.05896e-07, -1, 0, 0.453507, 1.10676, -0.588859)
bones/37/enabled = true
bones/37/position = Vector3(0.453507, 1.10676, -0.588859)
bones/37/rotation = Quaternion(-0.707107, -7.27952e-08, -7.27952e-08, 0.707107)
bones/37/rotation = Quaternion(-0.707107, -7.27951e-08, -7.27951e-08, 0.707107)
bones/37/scale = Vector3(1, 1, 1)
bones/38/name = "handIK.l"
bones/38/parent = 0
bones/38/rest = Transform3D(-2.38419e-07, 1, -5.96046e-08, -5.96046e-08, 0, 1, 1, 1.78814e-07, 0, 0.713181, 1.10676, 2.54914e-07)
bones/38/enabled = true
bones/38/position = Vector3(0.713181, 1.10676, 2.54914e-07)
bones/38/rotation = Quaternion(0.5, 0.5, 0.5, -0.5)
bones/38/position = Vector3(0.520841, 0.780739, -0.0576374)
bones/38/rotation = Quaternion(0.794627, -1.2666e-07, 0.607098, -5.96046e-08)
bones/38/scale = Vector3(1, 1, 1)
bones/39/name = "elbowIK.r"
bones/39/parent = 0
bones/39/rest = Transform3D(1, 2.05896e-07, -2.84217e-14, 2.84217e-14, 0, 1, 2.05896e-07, -1, 0, -0.453507, 1.10676, -0.58886)
bones/39/enabled = true
bones/39/position = Vector3(-0.453507, 1.10676, -0.58886)
bones/39/rotation = Quaternion(-0.707107, -7.27952e-08, -7.27952e-08, 0.707107)
bones/39/rotation = Quaternion(-0.707107, -7.27951e-08, -7.27951e-08, 0.707107)
bones/39/scale = Vector3(1, 1, 1)
bones/40/name = "handIK.r"
bones/40/parent = 0
bones/40/rest = Transform3D(1.19209e-07, -1, -5.96046e-08, 5.96046e-08, -1.19209e-07, 1, -1, -1.78814e-07, 0, -0.713182, 1.10676, -8.51573e-08)
bones/40/enabled = true
bones/40/position = Vector3(-0.713182, 1.10676, -8.51573e-08)
bones/40/rotation = Quaternion(-0.5, 0.5, 0.5, 0.5)
bones/40/position = Vector3(-0.510844, 0.780739, 0.0597369)
bones/40/rotation = Quaternion(-0.758253, -1.82539e-07, 0.651961, -1.11759e-08)
bones/40/scale = Vector3(1, 1, 1)
[node name="Skeleton_Minion_ArmLeft" type="MeshInstance3D" parent="Skeleton_Minion/Rig/Skeleton3D"]
@ -70325,7 +70355,7 @@ libraries = {
}
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
transform = Transform3D(1.1, 0, 0, 0, 1.1, 0, 0, 0, 1.1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_a6wip")
[node name="CameraController" type="Node3D" parent="." node_paths=PackedStringArray("springArm3D")]

@ -4,14 +4,19 @@ namespace DRPGActionGame.Player.States;
public partial class AttackState : State
{
private Player2 player;
public override void _Ready() {
player = GetParent<Player2>();
player.Playback.Travel("attack");
base._Ready();
Player.Playback?.Travel("attack");
}
public override void _PhysicsProcess(double delta) {
Player.ChangeState(StateFactory.States.Idle);
}
public override void ExitState() {
GD.Print("Exit Attack state...");
QueueFree();
}
}

@ -3,13 +3,38 @@ using Godot;
namespace DRPGActionGame.Player.States;
public partial class IdleState : State {
private Player2 player;
public override void _Ready() {
player = GetParent<Player2>();
player.Playback.Travel("idle");
base._Ready();
Player.Playback?.Travel("idle");
}
public override void _Input(InputEvent @event) {
if (@event.IsAction("WalkLeft") || @event.IsAction("WalkRight") || @event.IsAction("WalkUp") || @event.IsAction("WalkDown")) {
Player.Direction = new(@event.GetActionStrength("WalkLeft") - @event.GetActionStrength("WalkRight"), 0, @event.GetActionStrength("WalkUp") - @event.GetActionStrength("WalkDown"));
Player.ChangeState(StateFactory.States.Move);
}
else if (@event.IsAction("Jump")) {
Vector3 velocity = Player.Velocity;
velocity.Y = Player.JUMP_VELOCITY;
Player.Velocity = velocity;
Player.ChangeState(StateFactory.States.Jump);
}
else if (@event.IsAction("Attack")) {
Player.ChangeState(StateFactory.States.Attack);
}
}
public override void _PhysicsProcess(double delta) {
Vector3 velocity = Player.Velocity;
velocity.X = Mathf.MoveToward(Player.Velocity.X, 0, Player.SPEED);
velocity.Z = Mathf.MoveToward(Player.Velocity.Z, 0, Player.SPEED);
Player.Velocity = velocity;
}
public override void ExitState() {
GD.Print("Exit Idle state...");
QueueFree();
}
}

@ -4,18 +4,20 @@ namespace DRPGActionGame.Player.States;
public partial class JumpState : State
{
private Player2 player;
public override void _Ready() {
player = GetParent<Player2>();
player.Playback.Travel("jump");
base._Ready();
Player.Playback?.Travel("jump");
}
public override void _PhysicsProcess(double delta) {
Vector3 velocity = player.Velocity;
if (velocity == Vector3.Zero) player.ChangeState(StateFactory.States.Idle);
Vector3 velocity = Player.Velocity;
if (velocity.Y == 0) Player.ChangeState(StateFactory.States.Idle);
Player.Velocity = velocity;
}
player.Velocity = velocity;
public override void ExitState() {
GD.Print("Exit jump state...");
QueueFree();
}
}

@ -3,21 +3,40 @@ using Godot;
namespace DRPGActionGame.Player.States;
public partial class MoveState : State {
private Player2 player;
public override void _Ready() {
player = GetParent<Player2>();
player.Playback.Travel("move");
base._Ready();
Player.Playback?.Travel("move");
}
public override void _Input(InputEvent @event) {
if (@event.IsAction("Jump")) {
Vector3 velocity = Player.Velocity;
velocity.Y = Player.JUMP_VELOCITY;
Player.Velocity = velocity;
Player.ChangeState(StateFactory.States.Jump);
}
else if (@event.IsAction("Attack")) {
Player.ChangeState(StateFactory.States.Attack);
}
}
public override void _PhysicsProcess(double delta) {
Vector3 velocity = player.Velocity;
velocity.X = player.Direction.X * Player2.SPEED;
velocity.Z = player.Direction.Z * Player2.SPEED;
Player.Direction = new(Input.GetActionStrength("WalkLeft") - Input.GetActionStrength("WalkRight"), 0, Input.GetActionStrength("WalkUp") - Input.GetActionStrength("WalkDown"));
Vector3 velocity = Player.Velocity;
if (velocity == Vector3.Zero) player.ChangeState(StateFactory.States.Idle);
velocity.X = Player.Direction.X * Player.SPEED;
velocity.Z = Player.Direction.Z * Player.SPEED;
player.Velocity = velocity;
if (Player.Direction == Vector3.Zero) Player.ChangeState(StateFactory.States.Idle);
Player.Velocity = velocity;
}
public override void ExitState() {
GD.Print("Exit move state...");
QueueFree();
}
}

@ -3,17 +3,18 @@ using Godot;
namespace DRPGActionGame.Player.States;
public abstract partial class State : Node2D {
public StateFactory.States ChangeState;
private AnimationNodeStateMachinePlayback animation;
private Player2 persistantState;
private StateFactory.States actualState;
private AnimationNodeStateMachinePlayback? animation;
protected Player Player = new();
public abstract void ExitState();
public void Exit() => QueueFree();
public override void _Ready() => Player = GetParent<Player>();
public void Setup(StateFactory.States cS, AnimationNodeStateMachinePlayback a, Player2 pS) {
Name = cS.ToString();
public void Setup(StateFactory.States newState, AnimationNodeStateMachinePlayback? newAnimation, Player newPlayer) {
Name = newState.ToString();
GD.Print($"Current State: {Name}");
ChangeState = cS;
animation = a;
persistantState = pS;
actualState = newState;
animation = newAnimation;
Player = newPlayer;
}
}

@ -20,5 +20,5 @@ public partial class StateFactory : Node {
{States.Jump, new JumpState()}
};
public State GetState(States state) => CollectionExtensions.GetValueOrDefault(states, state);
public State? GetState(States state) => CollectionExtensions.GetValueOrDefault(states, state);
}

@ -1,5 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://dfy2rn0ryl0gw"]
[gd_scene load_steps=9 format=3 uid="uid://dfy2rn0ryl0gw"]
[ext_resource type="Texture2D" uid="uid://bs8serpgyphv5" path="res://Assets/texture_10.png" id="1_2xwws"]
[ext_resource type="PackedScene" uid="uid://cbn878rbtj1a8" path="res://Player/Player2.tscn" id="2_6l1py"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_lcthy"]
@ -18,13 +19,14 @@ ssil_enabled = true
sdfgi_enabled = true
glow_enabled = true
fog_light_color = Color(0.64243, 0.468412, 0.674277, 1)
volumetric_fog_enabled = true
volumetric_fog_density = 0.025
volumetric_fog_albedo = Color(0.927035, 0.613716, 0.636789, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tlh1r"]
albedo_color = Color(0.105676, 0.213448, 0.107403, 1)
albedo_texture = ExtResource("1_2xwws")
albedo_texture_force_srgb = true
emission = Color(0.298105, 0.540396, 0.310407, 1)
uv1_scale = Vector3(50, 50, 50)
[sub_resource type="PlaneMesh" id="PlaneMesh_sigdj"]
material = SubResource("StandardMaterial3D_tlh1r")
@ -44,12 +46,12 @@ shadow_enabled = true
[node name="Floor" type="StaticBody3D" parent="."]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor"]
transform = Transform3D(50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0, 0)
transform = Transform3D(50, 0, 0, 0, 1, 0, 0, 0, 50, 0, 0.6, 0)
mesh = SubResource("PlaneMesh_sigdj")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor"]
shape = SubResource("BoxShape3D_aivjm")
[node name="Player2" parent="." node_paths=PackedStringArray("animationTree") instance=ExtResource("2_6l1py")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.554, 0, -1.618)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.554, 15.928, -1.618)
animationTree = NodePath("AnimationTree")

@ -64,6 +64,11 @@ Jump={
, 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":4194309,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
Attack={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(85, 11),"global_position":Vector2(89, 52),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
[rendering]