From 0402226acc7edc22198ecf42720df65b781104bc Mon Sep 17 00:00:00 2001 From: raa Date: Thu, 14 Nov 2024 23:22:35 +0100 Subject: [PATCH] KST-1 --- .../.idea/vcs.xml | 6 ++ .../CharacterMovementController.cs | 10 +- .../RootMotionBasePlayerState.cs | 17 ++- Entities/Player/Player.tscn | 102 +++++++++--------- 4 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 .idea/.idea.Karrot Starter Template/.idea/vcs.xml diff --git a/.idea/.idea.Karrot Starter Template/.idea/vcs.xml b/.idea/.idea.Karrot Starter Template/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/.idea.Karrot Starter Template/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Common/CharacterMovement/CharacterMovementController.cs b/Common/CharacterMovement/CharacterMovementController.cs index 1ed8101..6dd357c 100644 --- a/Common/CharacterMovement/CharacterMovementController.cs +++ b/Common/CharacterMovement/CharacterMovementController.cs @@ -49,7 +49,7 @@ public partial class CharacterMovementController : Node if (v.rotationRate > 0) { Vector3 c = characterBody.GlobalRotation; - characterBody.GlobalRotation = new Vector3(0, Mathf.LerpAngle(c.Y, -Mathf.Atan2(velocity.X, -velocity.Z), Mathf.DegToRad(v.rotationRate) * (float)delta) , 0); + characterBody.GlobalRotation = new Vector3(0, Mathf.LerpAngle(c.Y, Mathf.Atan2(velocity.X, velocity.Z), Mathf.DegToRad(v.rotationRate) * (float)delta) , 0); // characterBody.LookAt(characterBody.GlobalPosition + velocity); } } @@ -75,9 +75,9 @@ public partial class CharacterMovementController : Node public override void _Process(double delta) { float x = characterBody.GlobalTransform.Basis.X.Dot(characterBody.Velocity); - float z = characterBody.GlobalTransform.Basis.Z.Dot(characterBody.Velocity) * -1; + float z = characterBody.GlobalTransform.Basis.Z.Dot(characterBody.Velocity); - blendspacePosition = blendspacePosition.MoveToward(new Vector2(x, z) , 4 * (float)delta * 1f); + blendspacePosition = blendspacePosition.MoveToward(new Vector2(x, z) , 6 * (float)delta * 1f); } public void SetMovementMode(CharacterMovementMode movementMode) @@ -95,6 +95,8 @@ public partial class CharacterMovementController : Node { direction = new Vector3(direction.X, 0f, direction.Z); } - _temporaryMovementDirection += direction * value; + + _temporaryMovementDirection += direction.Normalized() * value; + GD.Print( _temporaryMovementDirection); } } \ No newline at end of file diff --git a/Common/StateMachines/Custom/PlayerStateMachines/RootMotionBasePlayerState.cs b/Common/StateMachines/Custom/PlayerStateMachines/RootMotionBasePlayerState.cs index 145e8d7..05dbb27 100644 --- a/Common/StateMachines/Custom/PlayerStateMachines/RootMotionBasePlayerState.cs +++ b/Common/StateMachines/Custom/PlayerStateMachines/RootMotionBasePlayerState.cs @@ -32,9 +32,8 @@ public partial class RootMotionBasePlayerState : BasePlayerState protected override void OnStateProcess(double delta) { - - var (x, y, z) = animationTree.GetRootMotionPosition() / 2f; - _velocity += new Vector3(-x, y, -z); + + _velocity = animationTree.GetRootMotionPosition(); base.OnStateProcess(delta); } @@ -44,15 +43,15 @@ public partial class RootMotionBasePlayerState : BasePlayerState { _animationDirection = GetRootMotionDirection(); } - + if (_animationDirection != Vector3.Zero) { characterBody.GlobalRotation = new Vector3(0, Mathf.LerpAngle(characterBody.GlobalRotation.Y, - -Mathf.Atan2(_animationDirection.X, -_animationDirection.Z), 10 * (float)delta), 0); + Mathf.Atan2(_animationDirection.X, _animationDirection.Z), 10 * (float)delta), 0); } - - + + Quaternion rotationQuaternion = characterBody.Transform.Basis.GetRotationQuaternion(); characterBody.Velocity = rotationQuaternion.Normalized() * _velocity / (float)delta; @@ -68,13 +67,13 @@ public partial class RootMotionBasePlayerState : BasePlayerState temp = noInputDirectionTypeFallback; } - + switch (temp) { case ERootMotionAnimationDirection.Character: return Vector3.Zero; case ERootMotionAnimationDirection.Camera: - return (-cameraController.camera.GlobalBasis.Z); + return (cameraController.camera.GlobalBasis.Z); case ERootMotionAnimationDirection.Input: return (cameraController.camera.GlobalBasis.Z * package.GetVector3("move_direction").Y) + cameraController.camera.GlobalBasis.X * package.GetVector3("move_direction").X; diff --git a/Entities/Player/Player.tscn b/Entities/Player/Player.tscn index bca8870..55f6adf 100644 --- a/Entities/Player/Player.tscn +++ b/Entities/Player/Player.tscn @@ -20,7 +20,7 @@ ignoreUpDirection = true acceleration = 1.0 deceleration = 1.0 gravityScale = 1.0 -rotationRate = 0.0 +rotationRate = 720.0 [sub_resource type="Resource" id="Resource_gjtqv"] script = ExtResource("2_bpavf") @@ -198,6 +198,7 @@ top_level = true script = ExtResource("1_8tlkf") characterToFollow = NodePath("..") inputType = 1 +rotatePlayer = false [node name="SpringArm3D" type="SpringArm3D" parent="CameraController"] transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 0.9, 0) @@ -213,84 +214,83 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) shape = SubResource("CapsuleShape3D_inwpe") [node name="XBot2" parent="." instance=ExtResource("2_mdp28")] -transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) [node name="Skeleton3D" parent="XBot2/XBot" index="0"] bones/0/position = Vector3(-0.0094865, 1.25185e-09, 0.0105013) -bones/1/position = Vector3(-6.41051e-08, 1.01664, 0.0152059) -bones/1/rotation = Quaternion(-0.00179556, 0.0132419, -0.0480843, 0.998754) +bones/1/position = Vector3(-6.41927e-08, 1.01631, 0.0152016) +bones/1/rotation = Quaternion(-0.00247957, 0.0129864, -0.0472108, 0.998798) bones/1/scale = Vector3(1, 1, 1) -bones/2/rotation = Quaternion(-0.0736139, -0.0134737, 0.0248121, 0.996887) -bones/3/rotation = Quaternion(-0.00239047, -0.00699569, 0.0513199, 0.998655) -bones/4/rotation = Quaternion(0.0104128, -0.000845129, 0.0512795, 0.99863) -bones/5/rotation = Quaternion(0.00871049, -0.000173571, -0.0189319, 0.999783) -bones/6/rotation = Quaternion(0.0126036, 0.0132224, -0.0693042, 0.997428) -bones/8/rotation = Quaternion(-0.499466, 0.604869, -0.464923, -0.410503) +bones/2/rotation = Quaternion(-0.0698184, -0.0129161, 0.0256771, 0.997146) +bones/3/rotation = Quaternion(0.00547454, -0.00584693, 0.0515948, 0.998636) +bones/4/rotation = Quaternion(0.0184056, -0.000504125, 0.051505, 0.998503) +bones/5/rotation = Quaternion(0.00914212, -0.000186271, -0.0190842, 0.999776) +bones/6/rotation = Quaternion(0.0126122, 0.0143696, -0.0704965, 0.997329) +bones/8/rotation = Quaternion(-0.531587, 0.566702, -0.504636, -0.376306) bones/8/scale = Vector3(1, 1, 1) -bones/9/rotation = Quaternion(0.560569, -0.0574147, -0.0996368, 0.820084) +bones/9/rotation = Quaternion(0.501431, -0.0460958, -0.100924, 0.858054) bones/9/scale = Vector3(1, 1, 1) bones/10/rotation = Quaternion(1.8569e-07, 0.0161147, -0.153321, 0.988045) -bones/11/rotation = Quaternion(0.0963542, 0.0892781, 0.0727252, 0.988664) -bones/12/rotation = Quaternion(0.20961, -0.115532, -0.245184, 0.939468) -bones/13/rotation = Quaternion(-0.0328722, 0.117535, 0.240875, 0.962852) -bones/14/rotation = Quaternion(0.0098325, 0.00866698, 0.0611068, 0.998045) +bones/11/rotation = Quaternion(0.095522, 0.0923463, 0.0744244, 0.988336) +bones/12/rotation = Quaternion(0.201931, -0.119959, -0.227735, 0.944971) +bones/13/rotation = Quaternion(-0.0353345, 0.118021, 0.260359, 0.95762) +bones/14/rotation = Quaternion(0.0048986, 0.0101232, 0.0807254, 0.996673) bones/15/rotation = Quaternion(0.00577591, -0.11751, -0.0487442, 0.991858) -bones/16/rotation = Quaternion(0.076983, 0.000872834, 0.0413773, 0.996173) -bones/17/rotation = Quaternion(0.187029, 0.00118425, 0.0259622, 0.982011) -bones/18/rotation = Quaternion(0.129271, 0.00198141, 0.00248517, 0.991604) +bones/16/rotation = Quaternion(0.0690583, 0.000604117, 0.0405904, 0.996786) +bones/17/rotation = Quaternion(0.179214, 0.00112804, 0.0251818, 0.983487) +bones/18/rotation = Quaternion(0.121384, 0.00189872, 0.00167228, 0.992603) bones/19/rotation = Quaternion(-4.38752e-06, 0.00100281, 8.70747e-05, 0.999999) bones/19/scale = Vector3(1, 1, 1) -bones/20/rotation = Quaternion(0.145602, 0.000472066, 0.0766729, 0.986368) -bones/21/rotation = Quaternion(0.295346, 0.00265771, 0.0372965, 0.954658) -bones/22/rotation = Quaternion(0.146972, 0.000127494, 0.0154105, 0.989021) +bones/20/rotation = Quaternion(0.137738, 0.000212801, 0.0759617, 0.987551) +bones/21/rotation = Quaternion(0.287733, 0.00258121, 0.0365516, 0.95701) +bones/22/rotation = Quaternion(0.139102, 0.000123025, 0.014624, 0.99017) bones/23/rotation = Quaternion(-4.20033e-06, 0.000929157, 0.000166562, 1) -bones/24/rotation = Quaternion(0.207537, -0.00143193, 0.101306, 0.972966) -bones/25/rotation = Quaternion(0.321751, -0.00227888, 0.0346621, 0.946187) +bones/24/rotation = Quaternion(0.227202, -0.00122331, 0.103183, 0.968365) +bones/25/rotation = Quaternion(0.340889, -0.0024133, 0.0365495, 0.93939) bones/25/scale = Vector3(1, 1, 1) -bones/26/rotation = Quaternion(0.132543, 0.00115782, -0.00290896, 0.991172) +bones/26/rotation = Quaternion(0.152564, 0.00128253, -0.000861315, 0.988292) bones/27/rotation = Quaternion(1.16963e-07, 0.000146031, -0.000799608, 1) bones/27/scale = Vector3(1, 1, 1) -bones/28/rotation = Quaternion(0.286267, -0.0114882, 0.143446, 0.947282) -bones/29/rotation = Quaternion(0.366356, 0.00288045, 0.0361342, 0.929769) -bones/30/rotation = Quaternion(0.169731, 0.0059579, -0.00192036, 0.985471) +bones/28/rotation = Quaternion(0.305339, -0.00917991, 0.145624, 0.940998) +bones/29/rotation = Quaternion(0.385084, 0.00302773, 0.0380203, 0.922093) +bones/30/rotation = Quaternion(0.189615, 0.00649094, 0.000176252, 0.981837) bones/31/rotation = Quaternion(-5.56963e-06, 0.00156976, -4.12096e-05, 0.999999) bones/31/scale = Vector3(1, 1, 1) -bones/32/rotation = Quaternion(0.543159, 0.554221, -0.424813, 0.46621) +bones/32/rotation = Quaternion(0.57964, 0.518301, -0.463976, 0.42439) bones/32/scale = Vector3(1, 1, 1) -bones/33/rotation = Quaternion(0.676318, 0.0859955, 0.0300173, 0.730956) +bones/33/rotation = Quaternion(0.616365, 0.0723652, 0.0344348, 0.783372) bones/34/rotation = Quaternion(7.64858e-07, -0.0131976, 0.125566, 0.991998) -bones/35/rotation = Quaternion(0.0846856, -0.232848, -0.0325239, 0.968273) -bones/36/rotation = Quaternion(0.209579, 0.11587, 0.244299, 0.939664) -bones/37/rotation = Quaternion(-0.0324759, -0.117633, -0.239861, 0.963107) +bones/35/rotation = Quaternion(0.0884655, -0.234723, -0.0298803, 0.967567) +bones/36/rotation = Quaternion(0.201898, 0.120302, 0.226847, 0.945148) +bones/37/rotation = Quaternion(-0.0349368, -0.118116, -0.259351, 0.957896) bones/37/scale = Vector3(1, 1, 1) -bones/38/rotation = Quaternion(0.002646, -0.00797333, -0.0674098, 0.99769) +bones/38/rotation = Quaternion(-0.00224559, -0.00931581, -0.0869592, 0.996166) bones/39/rotation = Quaternion(0.00515115, 0.122683, 0.0416519, 0.991558) bones/39/scale = Vector3(1, 1, 1) -bones/40/rotation = Quaternion(0.076984, -0.000888905, -0.0415842, 0.996164) -bones/41/rotation = Quaternion(0.187036, -0.00111654, -0.0256068, 0.982019) -bones/42/rotation = Quaternion(0.0974016, -0.000353537, -0.00808231, 0.995212) +bones/40/rotation = Quaternion(0.0690592, -0.000618582, -0.0407974, 0.996778) +bones/41/rotation = Quaternion(0.179221, -0.00106319, -0.0248258, 0.983495) +bones/42/rotation = Quaternion(0.0894853, -0.000338478, -0.00727971, 0.995961) bones/43/rotation = Quaternion(-4.301e-06, -0.000377563, -1.30879e-05, 1) -bones/44/rotation = Quaternion(0.145602, -0.000549914, -0.0771981, 0.986327) -bones/45/rotation = Quaternion(0.295354, -0.00240048, -0.036463, 0.954689) -bones/46/rotation = Quaternion(0.115547, 9.80968e-05, -0.0139298, 0.993204) +bones/44/rotation = Quaternion(0.137738, -0.000286394, -0.0764874, 0.987511) +bones/45/rotation = Quaternion(0.287741, -0.00233063, -0.0357161, 0.957039) +bones/46/rotation = Quaternion(0.107645, 9.41972e-05, -0.0131421, 0.994103) bones/47/rotation = Quaternion(2.8699e-08, -0.00102401, 2.80073e-05, 0.999999) -bones/48/rotation = Quaternion(0.207545, 0.00146526, -0.101148, 0.972981) -bones/49/rotation = Quaternion(0.321757, 0.00220729, -0.0348695, 0.946177) -bones/50/rotation = Quaternion(0.14565, 0.00178051, -0.0143766, 0.98923) -bones/52/rotation = Quaternion(0.286229, 0.012221, -0.141014, 0.947649) -bones/53/rotation = Quaternion(0.366355, -0.00264843, -0.0355409, 0.929793) -bones/54/rotation = Quaternion(0.155789, -0.000245093, -0.0231177, 0.98752) +bones/48/rotation = Quaternion(0.227193, 0.00125991, -0.103024, 0.968384) +bones/49/rotation = Quaternion(0.340904, 0.00233736, -0.036756, 0.939377) +bones/50/rotation = Quaternion(0.165632, 0.00197345, -0.0163592, 0.98605) +bones/52/rotation = Quaternion(0.305307, 0.00996131, -0.143208, 0.941371) +bones/53/rotation = Quaternion(0.385083, -0.00278365, -0.0374319, 0.922118) +bones/54/rotation = Quaternion(0.175725, -0.000267522, -0.0250954, 0.984119) bones/55/scale = Vector3(1, 1, 1) -bones/56/rotation = Quaternion(-0.0408944, 0.023228, 0.994313, -0.0955542) -bones/57/rotation = Quaternion(-0.138434, 0.0462629, 0.0241615, 0.988996) -bones/58/rotation = Quaternion(0.532354, -0.0301416, -0.062088, 0.843703) +bones/56/rotation = Quaternion(-0.0412592, 0.0247158, 0.994295, -0.0952081) +bones/57/rotation = Quaternion(-0.140992, 0.046549, 0.0250575, 0.988598) +bones/58/rotation = Quaternion(0.532883, -0.0307157, -0.063444, 0.843248) bones/58/scale = Vector3(1, 1, 1) bones/59/rotation = Quaternion(0.340057, 5.86679e-08, -2.64737e-07, 0.940405) bones/60/rotation = Quaternion(3.66699e-08, 0.0116081, 4.25779e-10, 0.999933) -bones/61/rotation = Quaternion(0.114339, 0.173645, 0.970395, -0.122915) +bones/61/rotation = Quaternion(0.114678, 0.173256, 0.970346, -0.12353) bones/61/scale = Vector3(1, 1, 1) -bones/62/rotation = Quaternion(-0.24838, -0.0782927, 0.0351752, 0.964852) -bones/63/rotation = Quaternion(0.487247, -0.0631822, -0.0782306, 0.867455) +bones/62/rotation = Quaternion(-0.249285, -0.0774856, 0.0350244, 0.96469) +bones/63/rotation = Quaternion(0.485928, -0.0641199, -0.0783549, 0.868115) bones/64/rotation = Quaternion(0.339131, 1.59574e-07, -4.75502e-07, 0.940739) bones/65/rotation = Quaternion(4.9911e-08, -0.0118692, -5.92394e-10, 0.99993)