From c074df400445b18a08550ff80e8d0703ecba7e8a Mon Sep 17 00:00:00 2001 From: ywmaa Date: Fri, 19 Jan 2024 23:35:11 +0200 Subject: [PATCH] Orientation Warping Fix | Mantle System Base --- AMSG_Examples/Character/mixamo_character.tscn | 128 +++++++++--------- AMSG_Examples/Player/Player.tscn | 8 +- .../Components/CharacterMovementComponent.gd | 114 +++++----------- .../MantleComponent/MantleComponent.gd | 65 +++++++++ .../MantleComponent/MantleComponent.tscn | 27 ++++ addons/PoseWarping/PoseWarping.gd | 35 +++-- addons/PoseWarping/PoseWarping.tscn | 6 + 7 files changed, 225 insertions(+), 158 deletions(-) create mode 100644 addons/AMSG/Components/MantleComponent/MantleComponent.gd create mode 100644 addons/AMSG/Components/MantleComponent/MantleComponent.tscn diff --git a/AMSG_Examples/Character/mixamo_character.tscn b/AMSG_Examples/Character/mixamo_character.tscn index 94b0410..5de1ffe 100644 --- a/AMSG_Examples/Character/mixamo_character.tscn +++ b/AMSG_Examples/Character/mixamo_character.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=56 format=3 uid="uid://cth47yn1duvdh"] +[gd_scene load_steps=57 format=3 uid="uid://cth47yn1duvdh"] [ext_resource type="PackedScene" uid="uid://ccqctdss4s6u5" path="res://addons/PoseWarping/PoseWarping.tscn" id="1_bk0at"] [ext_resource type="Script" path="res://addons/AMSG/Components/CharacterMovementComponent.gd" id="1_ewnep"] @@ -29,6 +29,7 @@ [ext_resource type="Animation" uid="uid://bl4cuhnoma34i" path="res://AMSG_Examples/Character/Animations/WalkingBackward.res" id="25_fd0ml"] [ext_resource type="Script" path="res://addons/AMSG/Components/Interaction.gd" id="26_8j4xc"] [ext_resource type="AudioStream" uid="uid://bpnobn6wg8hxp" path="res://AMSG_Examples/Character/footstep_sound/footstep2.wav" id="27_cpdra"] +[ext_resource type="PackedScene" uid="uid://dpniuhmc5sj82" path="res://addons/AMSG/Components/MantleComponent/MantleComponent.tscn" id="28_6ac02"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_5egkr"] _data = { @@ -197,7 +198,6 @@ node_connections = [&"JogFB", 0, &"JogForward", &"JogFB", 1, &"JogBackward", &"S [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_nuhxy"] resource_local_to_scene = true -graph_offset = Vector2(154.71, 687.984) nodes/AnimTurnLeft/node = SubResource("AnimationNodeAnimation_mb2kt") nodes/AnimTurnLeft/position = Vector2(500, 1540) nodes/AnimTurnRight/node = SubResource("AnimationNodeAnimation_2rfjg") @@ -218,7 +218,7 @@ node_connections = [&"InAir", 0, &"Turn", &"InAir", 1, &"FallAnimation", &"Right [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_70w0s"] resource_local_to_scene = true radius = 0.375 -height = 1.0 +height = 1.75 [sub_resource type="Skin" id="Skin_hh536"] resource_name = "Skin" @@ -432,7 +432,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.186, 0) target_position = Vector3(0, -0.4, 0) hit_from_inside = true -[node name="CharacterMovementComponent" type="Node" parent="." node_paths=PackedStringArray("mesh_ref", "anim_ref", "skeleton_ref", "collision_shape_ref", "camera_root", "character_node", "ground_check", "pose_warping")] +[node name="CharacterMovementComponent" type="Node" parent="." node_paths=PackedStringArray("mesh_ref", "anim_ref", "skeleton_ref", "collision_shape_ref", "camera_root", "character_node", "ground_check", "mantle_component", "pose_warping")] script = ExtResource("1_ewnep") mesh_ref = NodePath("../Armature") anim_ref = NodePath("../AnimationTree") @@ -441,9 +441,9 @@ collision_shape_ref = NodePath("../CollisionShape3D") camera_root = NodePath("../CameraComponent") character_node = NodePath("..") ground_check = NodePath("../GroundCheck") +mantle_component = NodePath("../Armature/Skeleton3D/MantleComponent") pose_warping = NodePath("../Armature/Skeleton3D/PoseWarping") -tilt = true -tilt_power = 10.0 +tilt_power = 0.0 deacceleration = 0.0 looking_direction_standing_data = ExtResource("2_c4o7m") looking_direction_crouch_data = ExtResource("3_p3fng") @@ -494,43 +494,43 @@ bones/0/name = "Hips" bones/0/parent = -1 bones/0/rest = Transform3D(0.544576, -0.0348814, -0.837986, 0.0102475, 0.999337, -0.0349382, 0.838649, 0.0104393, 0.544573, -0.000172998, 0.901879, -0.00179914) bones/0/enabled = true -bones/0/position = Vector3(0.000173653, 0.9851, -0.000482915) -bones/0/rotation = Quaternion(-0.0167262, 0.0113152, 0.0138154, 0.999701) +bones/0/position = Vector3(0.0133876, 0.936884, 0.020478) +bones/0/rotation = Quaternion(-0.00656786, 0.0965517, 0.0127174, 0.995225) bones/0/scale = Vector3(1, 1, 1) bones/1/name = "Spine" bones/1/parent = 0 bones/1/rest = Transform3D(0.99963, -0.0129189, 0.0239171, 0.01122, 0.997494, 0.0698543, -0.0247596, -0.0695601, 0.99727, 4.88944e-09, 0.0992349, -0.0122733) bones/1/enabled = true bones/1/position = Vector3(4.88944e-09, 0.0992349, -0.0122733) -bones/1/rotation = Quaternion(-0.0148123, 0.0196568, -0.00445028, 0.999687) +bones/1/rotation = Quaternion(-0.0229041, -0.0831827, 0.00234219, 0.996268) bones/1/scale = Vector3(1, 1, 1) bones/2/name = "Spine1" bones/2/parent = 1 bones/2/rest = Transform3D(0.99985, -0.015446, 0.00786788, 0.0155655, 0.999761, -0.0153596, -0.00762876, 0.0154798, 0.999851, -2.79397e-09, 0.11732, 1.86265e-09) bones/2/enabled = true bones/2/position = Vector3(-2.79397e-09, 0.11732, 1.86265e-09) -bones/2/rotation = Quaternion(0.00561278, 0.00546154, 0.000791967, 0.999969) +bones/2/rotation = Quaternion(0.00183818, -0.0230571, -0.000236633, 0.999732) bones/2/scale = Vector3(1, 1, 1) bones/3/name = "Spine2" bones/3/parent = 2 bones/3/rest = Transform3D(0.999844, -0.014346, 0.0103258, 0.0156141, 0.990645, -0.135571, -0.00828427, 0.135711, 0.990714, -2.79397e-09, 0.134588, -2.51457e-08) bones/3/enabled = true bones/3/position = Vector3(-2.79397e-09, 0.134588, -2.51457e-08) -bones/3/rotation = Quaternion(0.0659498, 0.00546589, 0.000440576, 0.997808) +bones/3/rotation = Quaternion(0.062191, -0.0230232, 0.00125365, 0.997798) bones/3/scale = Vector3(1, 1, 1) bones/4/name = "Neck" bones/4/parent = 3 bones/4/rest = Transform3D(0.968778, 0.12654, 0.213204, -0.00181599, 0.863542, -0.504273, -0.247921, 0.488142, 0.836811, 2.48197e-07, 0.150325, 0.00792907) bones/4/enabled = true bones/4/position = Vector3(2.48197e-07, 0.150325, 0.00792907) -bones/4/rotation = Quaternion(0.137871, -0.00435551, 0.000939116, 0.99044) +bones/4/rotation = Quaternion(0.133564, 0.00294991, -0.0034408, 0.99103) bones/4/scale = Vector3(1, 1, 1) bones/5/name = "Head" bones/5/parent = 4 bones/5/rest = Transform3D(0.840773, 0.330252, 0.428993, -0.33245, 0.940342, -0.0723432, -0.427291, -0.0817944, 0.900406, 5.58794e-09, 0.107895, 5.21541e-08) bones/5/enabled = true bones/5/position = Vector3(5.58794e-09, 0.107895, 5.21541e-08) -bones/5/rotation = Quaternion(-0.00576365, -0.043142, -0.00877713, 0.999014) +bones/5/rotation = Quaternion(0.00222489, -0.0109032, -0.0124244, 0.999861) bones/5/scale = Vector3(1, 1, 1) bones/6/name = "HeadTop_End" bones/6/parent = 5 @@ -558,49 +558,49 @@ bones/9/parent = 3 bones/9/rest = Transform3D(-0.250988, 0.959361, -0.128958, 0.025503, -0.126623, -0.991623, -0.967654, -0.252174, 0.0073142, 0.0610582, 0.0911044, 0.00705553) bones/9/enabled = true bones/9/position = Vector3(0.0610582, 0.0911044, 0.00705553) -bones/9/rotation = Quaternion(-0.550598, -0.456619, 0.601711, -0.355366) +bones/9/rotation = Quaternion(-0.577464, -0.435062, 0.584563, -0.368161) bones/9/scale = Vector3(1, 1, 1) bones/10/name = "LeftArm" bones/10/parent = 9 bones/10/rest = Transform3D(0.845869, -0.51692, -0.131522, 0.093338, 0.386222, -0.917671, 0.52516, 0.763954, 0.374941, 7.45058e-09, 0.129223, 3.95812e-08) bones/10/enabled = true bones/10/position = Vector3(7.45058e-09, 0.129223, 3.95812e-08) -bones/10/rotation = Quaternion(0.514469, 0.11011, 0.106504, 0.843715) +bones/10/rotation = Quaternion(0.382833, 0.00660452, 0.325751, 0.864455) bones/10/scale = Vector3(1, 1, 1) bones/11/name = "LeftForeArm" bones/11/parent = 10 bones/11/rest = Transform3D(0.138967, -0.989426, 0.0415226, 0.989436, 0.140472, 0.0358277, -0.0412816, 0.0361051, 0.998495, -4.47035e-08, 0.274229, -7.45058e-09) bones/11/enabled = true bones/11/position = Vector3(-4.47035e-08, 0.274229, -7.45058e-09) -bones/11/rotation = Quaternion(9.83666e-05, 0.036134, 0.103917, 0.99393) +bones/11/rotation = Quaternion(0.000308475, 0.0351343, 0.255242, 0.966239) bones/11/scale = Vector3(1, 1, 1) bones/12/name = "LeftHand" bones/12/parent = 11 bones/12/rest = Transform3D(0.746359, -0.304314, 0.591895, 0.184003, 0.949028, 0.255908, -0.639601, -0.0820888, 0.764311, 6.0536e-09, 0.276326, -1.49012e-08) bones/12/enabled = true bones/12/position = Vector3(6.0536e-09, 0.276326, -1.49012e-08) -bones/12/rotation = Quaternion(-0.0261355, 0.113649, 0.00742869, 0.993149) +bones/12/rotation = Quaternion(-0.126266, -0.0722827, 0.0805157, 0.986078) bones/12/scale = Vector3(1, 1, 1) bones/13/name = "LeftHandMiddle1" bones/13/parent = 12 bones/13/rest = Transform3D(0.98654, 0.118644, -0.112532, -0.118809, 0.0472127, -0.991794, -0.112357, 0.991814, 0.0606732, -3.12924e-07, 0.127755, -7.63685e-08) bones/13/enabled = true bones/13/position = Vector3(-3.12924e-07, 0.127755, -7.63685e-08) -bones/13/rotation = Quaternion(0.339958, -0.00579685, -0.0559684, 0.938756) +bones/13/rotation = Quaternion(0.286876, -0.00603298, -0.046823, 0.956804) bones/13/scale = Vector3(1, 1, 1) bones/14/name = "LeftHandMiddle2" bones/14/parent = 13 bones/14/rest = Transform3D(0.980685, 0.110739, -0.161229, -0.112737, -0.353585, -0.928584, -0.159838, 0.928824, -0.334271, -7.45058e-09, 0.0361397, -5.21541e-08) bones/14/enabled = true bones/14/position = Vector3(-7.45058e-09, 0.0361397, -5.21541e-08) -bones/14/rotation = Quaternion(0.282836, -8.79168e-07, -0.0287405, 0.958738) +bones/14/rotation = Quaternion(0.233638, -6.78003e-07, -0.0237419, 0.972034) bones/14/scale = Vector3(1, 1, 1) bones/15/name = "LeftHandMiddle3" bones/15/parent = 14 bones/15/rest = Transform3D(0.981085, 0.112002, -0.157883, -0.108383, -0.357956, -0.927427, -0.160389, 0.926997, -0.339046, 0, 0.0345975, 7.07805e-08) bones/15/enabled = true bones/15/position = Vector3(0, 0.0345975, 7.07805e-08) -bones/15/rotation = Quaternion(0.19418, 1.37836e-06, -0.0197214, 0.980768) +bones/15/rotation = Quaternion(0.148777, 1.05053e-06, -0.0151084, 0.988755) bones/15/scale = Vector3(1, 1, 1) bones/16/name = "LeftHandMiddle4" bones/16/parent = 15 @@ -621,14 +621,14 @@ bones/18/parent = 17 bones/18/rest = Transform3D(0.793061, 0.491162, -0.360297, -0.562049, 0.818065, -0.121947, 0.234851, 0.299216, 0.924832, 1.19209e-07, 0.0474499, -2.44938e-07) bones/18/enabled = true bones/18/position = Vector3(1.19209e-07, 0.0474499, -2.44938e-07) -bones/18/rotation = Quaternion(0.104316, 0.0252787, -0.214191, 0.970877) +bones/18/rotation = Quaternion(0.10197, 0.0270494, -0.209325, 0.972139) bones/18/scale = Vector3(1, 1, 1) bones/19/name = "LeftHandThumb3" bones/19/parent = 18 bones/19/rest = Transform3D(0.347552, 0.931585, -0.106567, -0.924718, 0.359352, 0.12555, 0.155256, 0.0549092, 0.986347, -1.11759e-07, 0.0438214, 3.72529e-08) bones/19/enabled = true bones/19/position = Vector3(-1.11759e-07, 0.0438214, 3.72529e-08) -bones/19/rotation = Quaternion(-0.215134, -0.0111348, 0.170806, 0.961467) +bones/19/rotation = Quaternion(-0.232044, -0.00385652, 0.182674, 0.955391) bones/19/scale = Vector3(1, 1, 1) bones/20/name = "LeftHandThumb4" bones/20/parent = 19 @@ -642,21 +642,21 @@ bones/21/parent = 12 bones/21/rest = Transform3D(0.983723, 0.142189, -0.109869, -0.119058, 0.0577917, -0.991204, -0.134589, 0.988151, 0.0737798, -0.0282207, 0.122666, 0.00231682) bones/21/enabled = true bones/21/position = Vector3(-0.0282207, 0.122666, 0.00231682) -bones/21/rotation = Quaternion(0.271461, -0.0117843, -0.0193488, 0.962183) +bones/21/rotation = Quaternion(0.211924, -0.0112666, -0.00691015, 0.977197) bones/21/scale = Vector3(1, 1, 1) bones/22/name = "LeftHandIndex2" bones/22/parent = 21 bones/22/rest = Transform3D(0.978949, 0.10384, -0.175717, -0.111366, -0.44972, -0.8862, -0.171047, 0.887113, -0.428688, 1.11759e-07, 0.0389198, -5.96046e-08) bones/22/enabled = true bones/22/position = Vector3(1.11759e-07, 0.0389198, -5.96046e-08) -bones/22/rotation = Quaternion(0.267947, -1.71363e-06, -0.0272303, 0.963049) +bones/22/rotation = Quaternion(0.213634, -1.37091e-06, -0.021712, 0.976673) bones/22/scale = Vector3(1, 1, 1) bones/23/name = "LeftHandIndex3" bones/23/parent = 22 bones/23/rest = Transform3D(0.981451, 0.113056, -0.15483, -0.109059, -0.334958, -0.9359, -0.15767, 0.935426, -0.316415, 3.72529e-08, 0.0341517, -1.11759e-08) bones/23/enabled = true bones/23/position = Vector3(3.72529e-08, 0.0341517, -1.11759e-08) -bones/23/rotation = Quaternion(0.159128, -1.9148e-06, -0.0161676, 0.987126) +bones/23/rotation = Quaternion(0.100549, -1.9744e-06, -0.0102159, 0.99488) bones/23/scale = Vector3(1, 1, 1) bones/24/name = "LeftHandIndex4" bones/24/parent = 23 @@ -670,21 +670,21 @@ bones/25/parent = 12 bones/25/rest = Transform3D(0.991492, 0.0540781, -0.118406, -0.118263, -0.00584495, -0.992965, -0.0543897, 0.99852, 0.000600219, 0.0221662, 0.12147, -9.90927e-05) bones/25/enabled = true bones/25/position = Vector3(0.0221662, 0.12147, -9.90927e-05) -bones/25/rotation = Quaternion(0.350348, 0.00668123, -0.0902931, 0.932233) +bones/25/rotation = Quaternion(0.299659, 0.00221775, -0.0749724, 0.951093) bones/25/scale = Vector3(1, 1, 1) bones/26/name = "LeftHandRing2" bones/26/parent = 25 bones/26/rest = Transform3D(0.981497, 0.113181, -0.154445, -0.116659, -0.286137, -0.951061, -0.151835, 0.951481, -0.267639, -3.72529e-08, 0.036012, -1.11759e-07) bones/26/enabled = true bones/26/position = Vector3(-3.72529e-08, 0.036012, -1.11759e-07) -bones/26/rotation = Quaternion(0.36306, -3.01003e-06, -0.0368956, 0.931035) +bones/26/rotation = Quaternion(0.322405, -2.59653e-06, -0.0327651, 0.946035) bones/26/scale = Vector3(1, 1, 1) bones/27/name = "LeftHandRing3" bones/27/parent = 26 bones/27/rest = Transform3D(0.98241, 0.115381, -0.146824, -0.113355, -0.256342, -0.959916, -0.148393, 0.959675, -0.238754, -4.09782e-08, 0.0330728, 0) bones/27/enabled = true bones/27/position = Vector3(-4.09782e-08, 0.0330728, 0) -bones/27/rotation = Quaternion(0.151721, 3.42727e-07, -0.0154122, 0.988303) +bones/27/rotation = Quaternion(0.103313, 1.93715e-07, -0.0104938, 0.994594) bones/27/scale = Vector3(1, 1, 1) bones/28/name = "LeftHandRing4" bones/28/parent = 27 @@ -698,21 +698,21 @@ bones/29/parent = 12 bones/29/rest = Transform3D(0.991785, 0.0101279, -0.127516, -0.126197, -0.0855001, -0.988314, -0.0209122, 0.996287, -0.0835196, 0.0472581, 0.109082, 0.00226384) bones/29/enabled = true bones/29/position = Vector3(0.0472581, 0.109082, 0.00226384) -bones/29/rotation = Quaternion(0.324452, -0.00329711, -0.0654249, 0.943631) +bones/29/rotation = Quaternion(0.270006, -0.00351245, -0.0531575, 0.961384) bones/29/scale = Vector3(1, 1, 1) bones/30/name = "LeftHandPinky2" bones/30/parent = 29 bones/30/rest = Transform3D(0.989305, 0.129006, -0.068066, -0.049097, -0.144898, -0.988228, -0.13735, 0.981001, -0.137015, -5.96046e-08, 0.0413669, -1.49012e-08) bones/30/enabled = true bones/30/position = Vector3(-5.96046e-08, 0.0413669, -1.49012e-08) -bones/30/rotation = Quaternion(0.256197, -2.57418e-06, -0.02604, 0.966274) +bones/30/rotation = Quaternion(0.206948, -2.22027e-06, -0.0210362, 0.978126) bones/30/scale = Vector3(1, 1, 1) bones/31/name = "LeftHandPinky3" bones/31/parent = 30 bones/31/rest = Transform3D(0.977834, 0.0980185, -0.185023, -0.0947121, -0.581029, -0.808353, -0.186738, 0.807959, -0.558866, -4.47035e-08, 0.0259482, 3.53903e-08) bones/31/enabled = true bones/31/position = Vector3(-4.47035e-08, 0.0259482, 3.53903e-08) -bones/31/rotation = Quaternion(0.185208, -1.11759e-07, -0.0188074, 0.982519) +bones/31/rotation = Quaternion(0.137891, -5.21541e-07, -0.0139999, 0.990348) bones/31/scale = Vector3(1, 1, 1) bones/32/name = "LeftHandPinky4" bones/32/parent = 31 @@ -726,49 +726,49 @@ bones/33/parent = 3 bones/33/rest = Transform3D(-0.214833, -0.949432, 0.228968, -0.0511495, -0.223182, -0.973434, 0.975311, -0.220837, -0.000616074, -0.061057, 0.0911053, 0.00705566) bones/33/enabled = true bones/33/position = Vector3(-0.061057, 0.0911053, 0.00705566) -bones/33/rotation = Quaternion(0.534855, -0.469403, 0.607654, 0.35263) +bones/33/rotation = Quaternion(0.512212, -0.485295, 0.622497, 0.338564) bones/33/scale = Vector3(1, 1, 1) bones/34/name = "RightArm" bones/34/parent = 33 bones/34/rest = Transform3D(0.555382, 0.714901, -0.424814, -0.786414, 0.285417, -0.547804, -0.270377, 0.63832, 0.720724, -2.23517e-08, 0.129223, 9.12696e-08) bones/34/enabled = true bones/34/position = Vector3(-2.23517e-08, 0.129223, 9.12696e-08) -bones/34/rotation = Quaternion(0.465523, -0.0290722, -0.227152, 0.854895) +bones/34/rotation = Quaternion(0.51707, -0.0554019, 0.0279549, 0.85369) bones/34/scale = Vector3(1, 1, 1) bones/35/name = "RightForeArm" bones/35/parent = 34 bones/35/rest = Transform3D(-0.491194, 0.870247, -0.0374029, -0.870282, -0.488505, 0.0630281, 0.0365786, 0.0635101, 0.997311, 7.45058e-09, 0.274776, -3.72529e-08) bones/35/enabled = true bones/35/position = Vector3(7.45058e-09, 0.274776, -3.72529e-08) -bones/35/rotation = Quaternion(0.000924051, -0.0702121, -0.253174, 0.964869) +bones/35/rotation = Quaternion(0.000349137, -0.0718339, -0.138728, 0.987722) bones/35/scale = Vector3(1, 1, 1) bones/36/name = "RightHand" bones/36/parent = 35 bones/36/rest = Transform3D(0.953663, 0.121098, 0.275431, -0.18063, 0.962538, 0.202223, -0.240624, -0.242603, 0.939811, 7.45058e-09, 0.276868, 5.96046e-08) bones/36/enabled = true bones/36/position = Vector3(7.45058e-09, 0.276868, 5.96046e-08) -bones/36/rotation = Quaternion(-0.0383468, 0.0686339, -0.0398927, 0.996106) +bones/36/rotation = Quaternion(0.0301975, -0.146344, 0.0553801, 0.987221) bones/36/scale = Vector3(1, 1, 1) bones/37/name = "RightHandMiddle1" bones/37/parent = 36 bones/37/rest = Transform3D(0.986308, -0.119644, 0.1135, 0.119813, 0.0469439, -0.991686, 0.113321, 0.991706, 0.060636, 3.50177e-07, 0.127755, -8.9407e-08) bones/37/enabled = true bones/37/position = Vector3(3.50177e-07, 0.127755, -8.9407e-08) -bones/37/rotation = Quaternion(0.304846, 0.00431531, 0.0478329, 0.95119) +bones/37/rotation = Quaternion(0.214752, 8.05836e-05, 0.0538795, 0.975181) bones/37/scale = Vector3(1, 1, 1) bones/38/name = "RightHandMiddle2" bones/38/parent = 37 bones/38/rest = Transform3D(0.980361, -0.111685, 0.162538, 0.114835, -0.346749, -0.930902, 0.160328, 0.931285, -0.327114, 6.70552e-08, 0.0361398, -1.02445e-07) bones/38/enabled = true bones/38/position = Vector3(6.70552e-08, 0.0361398, -1.02445e-07) -bones/38/rotation = Quaternion(0.329056, 1.03563e-06, 0.0264693, 0.943939) +bones/38/rotation = Quaternion(0.251403, 6.482e-07, 0.0202237, 0.967671) bones/38/scale = Vector3(1, 1, 1) bones/39/name = "RightHandMiddle3" bones/39/parent = 38 bones/39/rest = Transform3D(0.980787, -0.112947, 0.159059, 0.107057, -0.369977, -0.922852, 0.163081, 0.922149, -0.350778, 7.45058e-09, 0.0345976, -4.84288e-08) bones/39/enabled = true bones/39/position = Vector3(7.45058e-09, 0.0345976, -4.84288e-08) -bones/39/rotation = Quaternion(0.129425, -9.61126e-07, 0.0104023, 0.991535) +bones/39/rotation = Quaternion(0.0553324, -3.20375e-07, 0.00444282, 0.998458) bones/39/scale = Vector3(1, 1, 1) bones/40/name = "RightHandMiddle4" bones/40/parent = 39 @@ -789,14 +789,14 @@ bones/42/parent = 41 bones/42/rest = Transform3D(0.793791, -0.608189, -0.00159446, 0.595053, 0.777184, -0.204689, 0.125729, 0.161531, 0.978826, -1.2666e-07, 0.0474498, -2.68221e-07) bones/42/enabled = true bones/42/position = Vector3(-1.2666e-07, 0.0474498, -2.68221e-07) -bones/42/rotation = Quaternion(0.0351433, -0.0337446, 0.284211, 0.957523) +bones/42/rotation = Quaternion(0.007073, -0.0406278, 0.237663, 0.970472) bones/42/scale = Vector3(1, 1, 1) bones/43/name = "RightHandThumb3" bones/43/parent = 42 bones/43/rest = Transform3D(0.501426, -0.84416, 0.189648, 0.865092, 0.485702, -0.125336, 0.0136913, 0.226909, 0.973819, 1.56462e-07, 0.0438213, -9.87202e-08) bones/43/enabled = true bones/43/position = Vector3(1.56462e-07, 0.0438213, -9.87202e-08) -bones/43/rotation = Quaternion(-0.137593, -0.0686919, -0.134022, 0.978973) +bones/43/rotation = Quaternion(-0.175493, -0.0918232, -0.149539, 0.968715) bones/43/scale = Vector3(1, 1, 1) bones/44/name = "RightHandThumb4" bones/44/parent = 43 @@ -810,21 +810,21 @@ bones/45/parent = 36 bones/45/rest = Transform3D(0.978763, -0.172845, 0.110213, 0.120904, 0.0525683, -0.991271, 0.165542, 0.983545, 0.0723496, 0.0282207, 0.122666, 0.00231693) bones/45/enabled = true bones/45/position = Vector3(0.0282207, 0.122666, 0.00231693) -bones/45/rotation = Quaternion(0.193213, 0.00686499, 0.0171482, 0.980983) +bones/45/rotation = Quaternion(0.0985925, 0.00225035, 0.0178964, 0.994964) bones/45/scale = Vector3(1, 1, 1) bones/46/name = "RightHandIndex2" bones/46/parent = 45 bones/46/rest = Transform3D(0.978593, -0.104714, 0.177172, 0.106914, -0.476935, -0.872412, 0.175853, 0.872679, -0.45553, 1.49012e-07, 0.0389196, -8.75443e-08) bones/46/enabled = true bones/46/position = Vector3(1.49012e-07, 0.0389196, -8.75443e-08) -bones/46/rotation = Quaternion(0.352334, 5.21541e-07, 0.028345, 0.935445) +bones/46/rotation = Quaternion(0.259028, -1.49012e-08, 0.0208402, 0.965645) bones/46/scale = Vector3(1, 1, 1) bones/47/name = "RightHandIndex3" bones/47/parent = 46 bones/47/rest = Transform3D(0.981139, -0.114005, 0.156106, 0.114242, -0.309465, -0.944023, 0.155933, 0.944052, -0.290604, -7.45058e-09, 0.0341516, 5.96046e-08) bones/47/enabled = true bones/47/position = Vector3(-7.45058e-09, 0.0341516, 5.96046e-08) -bones/47/rotation = Quaternion(0.162531, -1.2666e-07, 0.0130727, 0.986617) +bones/47/rotation = Quaternion(0.0869244, -1.63913e-07, 0.00699165, 0.99619) bones/47/scale = Vector3(1, 1, 1) bones/48/name = "RightHandIndex4" bones/48/parent = 47 @@ -838,21 +838,21 @@ bones/49/parent = 36 bones/49/rest = Transform3D(0.991829, -0.0281871, 0.124419, 0.122843, -0.0520322, -0.991061, 0.0344089, 0.998247, -0.0481446, -0.0221661, 0.12147, -9.89214e-05) bones/49/enabled = true bones/49/position = Vector3(-0.0221661, 0.12147, -9.89214e-05) -bones/49/rotation = Quaternion(0.354808, -0.00444961, 0.076311, 0.931809) +bones/49/rotation = Quaternion(0.284454, -0.0079786, 0.0859797, 0.954793) bones/49/scale = Vector3(1, 1, 1) bones/50/name = "RightHandRing2" bones/50/parent = 49 bones/50/rest = Transform3D(0.982662, -0.117406, 0.143498, 0.122607, -0.169092, -0.977944, 0.139081, 0.978583, -0.151765, -7.45058e-09, 0.036012, 0) bones/50/enabled = true bones/50/position = Vector3(-7.45058e-09, 0.036012, 0) -bones/50/rotation = Quaternion(0.294119, 4.04567e-06, 0.0236633, 0.955476) +bones/50/rotation = Quaternion(0.223182, 3.48315e-06, 0.017958, 0.974611) bones/50/scale = Vector3(1, 1, 1) bones/51/name = "RightHandRing3" bones/51/parent = 50 bones/51/rest = Transform3D(0.982132, -0.116356, 0.147913, 0.107863, -0.296024, -0.949071, 0.154216, 0.948067, -0.278184, -2.23517e-08, 0.0330732, -8.9407e-08) bones/51/enabled = true bones/51/position = Vector3(-2.23517e-08, 0.0330732, -8.9407e-08) -bones/51/rotation = Quaternion(0.150822, -3.71039e-06, 0.0121283, 0.988487) +bones/51/rotation = Quaternion(0.0831442, -3.52412e-06, 0.00668463, 0.996515) bones/51/scale = Vector3(1, 1, 1) bones/52/name = "RightHandRing4" bones/52/parent = 51 @@ -866,21 +866,21 @@ bones/53/parent = 36 bones/53/rest = Transform3D(0.989897, 0.0602255, 0.128364, 0.133612, -0.0931972, -0.986642, -0.0474579, 0.993824, -0.100302, -0.047258, 0.109082, 0.00226358) bones/53/enabled = true bones/53/position = Vector3(-0.047258, 0.109082, 0.00226358) -bones/53/rotation = Quaternion(0.381414, 0.00932258, 0.044113, 0.923304) +bones/53/rotation = Quaternion(0.30704, 0.00260534, 0.0601345, 0.949791) bones/53/scale = Vector3(1, 1, 1) bones/54/name = "RightHandPinky2" bones/54/parent = 53 bones/54/rest = Transform3D(0.983236, -0.118306, 0.138749, 0.122507, -0.134994, -0.983244, 0.135054, 0.983758, -0.118237, -2.98023e-08, 0.0413665, 4.24334e-08) bones/54/enabled = true bones/54/position = Vector3(-2.98023e-08, 0.0413665, 4.24334e-08) -bones/54/rotation = Quaternion(0.32973, 3.5204e-06, 0.0265306, 0.943703) +bones/54/rotation = Quaternion(0.272652, 2.9467e-06, 0.0219399, 0.961863) bones/54/scale = Vector3(1, 1, 1) bones/55/name = "RightHandPinky3" bones/55/parent = 54 bones/55/rest = Transform3D(0.977459, -0.0988442, 0.186556, 0.0932951, -0.590451, -0.801664, 0.189392, 0.800998, -0.56792, -5.21541e-08, 0.0259486, -3.72529e-08) bones/55/enabled = true bones/55/position = Vector3(-5.21541e-08, 0.0259486, -3.72529e-08) -bones/55/rotation = Quaternion(0.227911, -2.49595e-06, 0.0183204, 0.97351) +bones/55/rotation = Quaternion(0.165435, -1.74344e-06, 0.0132953, 0.986131) bones/55/scale = Vector3(1, 1, 1) bones/56/name = "RightHandPinky4" bones/56/parent = 55 @@ -894,28 +894,28 @@ bones/57/parent = 0 bones/57/rest = Transform3D(-0.919821, -0.336213, -0.202214, 0.264978, -0.912457, 0.311783, -0.289337, 0.233202, 0.928386, -0.0912445, -0.0665637, -0.000553781) bones/57/enabled = true bones/57/position = Vector3(-0.0912445, -0.0665637, -0.000553781) -bones/57/rotation = Quaternion(-0.0903202, -0.0209729, 0.995686, 0.00354005) +bones/57/rotation = Quaternion(-0.051413, 0.27047, 0.96126, 0.0134798) bones/57/scale = Vector3(1, 1, 1) bones/58/name = "RightLeg" bones/58/parent = 57 bones/58/rest = Transform3D(0.997811, 0.0392429, -0.0532304, 0.00932048, 0.713425, 0.70067, 0.0654722, -0.699632, 0.711497, 4.84288e-08, 0.405994, 2.6077e-08) bones/58/enabled = true bones/58/position = Vector3(4.84288e-08, 0.405994, 2.6077e-08) -bones/58/rotation = Quaternion(-0.135363, 0.00201182, 0.0208232, 0.990575) +bones/58/rotation = Quaternion(-0.150393, 0.0814245, -0.019361, 0.985077) bones/58/scale = Vector3(1, 1, 1) bones/59/name = "RightFoot" bones/59/parent = 58 bones/59/rest = Transform3D(0.96994, -0.122934, 0.210008, 0.229929, 0.180407, -0.95634, 0.0796801, 0.975879, 0.20325, -1.02445e-08, 0.42099, 9.31323e-09) bones/59/enabled = true bones/59/position = Vector3(-1.02445e-08, 0.42099, 9.31323e-09) -bones/59/rotation = Quaternion(0.544462, -0.025231, -0.0655307, 0.835841) +bones/59/rotation = Quaternion(0.396655, -0.0117189, -0.0468712, 0.916696) bones/59/scale = Vector3(1, 1, 1) bones/60/name = "RightToeBase" bones/60/parent = 59 bones/60/rest = Transform3D(0.999367, 6.43255e-05, 0.0355612, 0.0227211, 0.768109, -0.639916, -0.027356, 0.640319, 0.767622, -5.51563e-09, 0.16432, -1.09159e-07) bones/60/enabled = true bones/60/position = Vector3(-5.51563e-09, 0.16432, -1.09159e-07) -bones/60/rotation = Quaternion(0.388148, 0.0170185, 0.00516053, 0.921425) +bones/60/rotation = Quaternion(0.397566, 0.0170704, 0.004986, 0.917401) bones/60/scale = Vector3(1, 1, 1) bones/61/name = "RightToe_End" bones/61/parent = 60 @@ -929,28 +929,28 @@ bones/62/parent = 0 bones/62/rest = Transform3D(-0.893651, 0.403296, 0.196826, -0.227377, -0.785047, 0.576195, 0.386895, 0.470164, 0.793258, 0.0912445, -0.0665636, -0.000553777) bones/62/enabled = true bones/62/position = Vector3(0.0912445, -0.0665636, -0.000553777) -bones/62/rotation = Quaternion(0.0354279, 0.2467, 0.968324, 0.0152771) +bones/62/rotation = Quaternion(0.0646029, -0.15248, 0.98602, -0.0184466) bones/62/scale = Vector3(1, 1, 1) bones/63/name = "LeftLeg" bones/63/parent = 62 bones/63/rest = Transform3D(0.99576, 0.0029921, 0.0919402, -0.056273, 0.810456, 0.583091, -0.0727688, -0.585792, 0.807188, 5.12227e-08, 0.405994, -2.04891e-08) bones/63/enabled = true bones/63/position = Vector3(5.12227e-08, 0.405994, -2.04891e-08) -bones/63/rotation = Quaternion(-0.335041, -0.0620619, 0.0123289, 0.940077) +bones/63/rotation = Quaternion(-0.196845, 0.0755206, 0.0180967, 0.977354) bones/63/scale = Vector3(1, 1, 1) bones/64/name = "LeftFoot" bones/64/parent = 63 bones/64/rest = Transform3D(0.977802, 0.128039, -0.165856, -0.209522, 0.59104, -0.778956, -0.00170929, 0.796415, 0.604748, -2.04891e-08, 0.42099, 6.98492e-09) bones/64/enabled = true bones/64/position = Vector3(-2.04891e-08, 0.42099, 6.98492e-09) -bones/64/rotation = Quaternion(0.449533, -0.00374515, -0.00141069, 0.893255) +bones/64/rotation = Quaternion(0.435056, 0.0338564, -0.00805083, 0.899731) bones/64/scale = Vector3(1, 1, 1) bones/65/name = "LeftToeBase" bones/65/parent = 64 bones/65/rest = Transform3D(0.999367, -0.000945242, -0.0355486, -0.0227206, 0.752033, -0.658734, 0.0273564, 0.659125, 0.751536, 3.66616e-08, 0.16432, -1.10293e-07) bones/65/enabled = true bones/65/position = Vector3(3.66616e-08, 0.16432, -1.10293e-07) -bones/65/rotation = Quaternion(0.34558, -0.0167644, -0.00593377, 0.938221) +bones/65/rotation = Quaternion(0.621119, -0.00791441, 0.00527677, 0.783659) bones/65/scale = Vector3(1, 1, 1) bones/66/name = "LeftToe_End" bones/66/parent = 65 @@ -969,7 +969,7 @@ mesh = ExtResource("6_e2l25") skin = SubResource("Skin_hh536") [node name="HeadBone" type="BoneAttachment3D" parent="Armature/Skeleton3D"] -transform = Transform3D(0.999616, 0.0260554, -0.00945916, -0.027719, 0.941224, -0.336643, 0.000131801, 0.336776, 0.941585, -0.00823619, 1.58562, 0.0270391) +transform = Transform3D(0.997557, -0.0260815, -0.0648099, 0.00247161, 0.940292, -0.340359, 0.0698173, 0.339367, 0.938059, -0.013147, 1.53803, 0.04861) bone_name = "Head" bone_idx = 5 @@ -978,7 +978,7 @@ process_priority = 1 root_bone = &"LeftUpLeg" tip_bone = &"LeftFoot" use_magnet = true -magnet = Vector3(0, 0, 1) +magnet = Vector3(0.25, 1, 1) target_node = NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Character/Armature/Skeleton3D/PoseWarping/LeftIKTarget") [node name="RightLegIK" type="SkeletonIK3D" parent="Armature/Skeleton3D"] @@ -986,13 +986,19 @@ process_priority = 1 root_bone = &"RightUpLeg" tip_bone = &"RightFoot" use_magnet = true -magnet = Vector3(0, 0, 1) +magnet = Vector3(-0.25, 1, 1) target_node = NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Character/Armature/Skeleton3D/PoseWarping/RightIKTarget") -[node name="PoseWarping" parent="Armature/Skeleton3D" node_paths=PackedStringArray("character_node", "LeftLegIK", "RightLegIK") instance=ExtResource("1_bk0at")] +[node name="PoseWarping" parent="Armature/Skeleton3D" node_paths=PackedStringArray("character_node", "LeftLegIK", "RightLegIK", "orientation_warping_camera_h_object") instance=ExtResource("1_bk0at")] character_node = NodePath("../../..") LeftLegIK = NodePath("../LeftLegIK") RightLegIK = NodePath("../RightLegIK") +orientation_warping_camera_h_object = NodePath("../../../SpringArm3D") + +[node name="MantleComponent" parent="Armature/Skeleton3D" node_paths=PackedStringArray("character_collision_shape", "character_node", "animation_tree") instance=ExtResource("28_6ac02")] +character_collision_shape = NodePath("../../../CollisionShape3D") +character_node = NodePath("../../..") +animation_tree = NodePath("../../../AnimationTree") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] libraries = { diff --git a/AMSG_Examples/Player/Player.tscn b/AMSG_Examples/Player/Player.tscn index 1d937e7..c8ddc06 100644 --- a/AMSG_Examples/Player/Player.tscn +++ b/AMSG_Examples/Player/Player.tscn @@ -334,18 +334,18 @@ transform = Transform3D(-0.776967, -0.466155, -0.423109, -0.0355596, -0.638521, transform = Transform3D(-0.303158, -0.739914, -0.600519, 0.0355596, -0.638519, 0.768784, -0.952277, 0.211709, 0.219883, -0.0315955, 0.104958, -0.310727) [node name="LeftFootAttachment" parent="Armature/Skeleton3D/PoseWarping" index="2"] -transform = Transform3D(-0.776963, -0.466153, -0.423106, -0.0355594, -0.638517, 0.768778, -0.628532, 0.612361, 0.479531, 0.0833106, 0.111479, 0.361883) +transform = Transform3D(-0.776963, -0.466153, -0.423106, -0.0355594, -0.638517, 0.768778, -0.628532, 0.612361, 0.479531, 0.0840908, 0.111218, 0.361871) external_skeleton = NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Character/Armature/Skeleton3D") [node name="RightFootAttachment" parent="Armature/Skeleton3D/PoseWarping" index="3"] -transform = Transform3D(-0.303158, -0.739914, -0.600519, 0.0355596, -0.638519, 0.768784, -0.952277, 0.211709, 0.219883, -0.0316372, 0.109252, -0.307104) +transform = Transform3D(-0.303158, -0.739914, -0.600519, 0.0355596, -0.638519, 0.768784, -0.952277, 0.211709, 0.219883, -0.0313653, 0.102962, -0.312327) external_skeleton = NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Character/Armature/Skeleton3D") [node name="LeftLegRayCast" parent="Armature/Skeleton3D/PoseWarping" index="4"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0833106, 0.361479, 0.361883) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0840908, 0.361218, 0.361871) [node name="RightLegRayCast" parent="Armature/Skeleton3D/PoseWarping" index="5"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0316372, 0.359252, -0.307104) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0313653, 0.352962, -0.312327) [node name="flashlight" parent="Armature" index="1" instance=ExtResource("5_euvsl")] transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1.12407, 0.156779) diff --git a/addons/AMSG/Components/CharacterMovementComponent.gd b/addons/AMSG/Components/CharacterMovementComponent.gd index ea6409f..a57500d 100644 --- a/addons/AMSG/Components/CharacterMovementComponent.gd +++ b/addons/AMSG/Components/CharacterMovementComponent.gd @@ -25,6 +25,7 @@ class_name CharacterMovementComponent @export var character_node : PhysicsBody3D ## Refrence to a [RayCast3D] that should detect if character is on ground @export var ground_check : RayCast3D +@export var mantle_component : MantleComponent @@ -248,6 +249,7 @@ func update_character_movement(): match rotation_mode: Global.rotation_mode.velocity_direction: tilt = false + pose_warping.orientation_warping_enable = false match stance: Global.stance.standing: current_movement_data = velocity_direction_standing_data @@ -257,6 +259,7 @@ func update_character_movement(): Global.rotation_mode.looking_direction: tilt = true + pose_warping.orientation_warping_enable = true match stance: Global.stance.standing: current_movement_data = looking_direction_standing_data @@ -265,6 +268,7 @@ func update_character_movement(): Global.rotation_mode.aiming: + pose_warping.orientation_warping_enable = true match stance: Global.stance.standing: current_movement_data = aim_standing_data @@ -299,77 +303,6 @@ func _process(delta): calc_animation_data() pose_warping.character_velocity = actual_velocity -#func stride_warping(target:Node3D, floor_normal:Vector3, skeleton_ref:Skeleton3D, hips_name:String, Foot:String, Thigh:String): - ##add_sibling(test_sphere) - ##add_sibling(test_sphere1) - # - ##skeleton_ref.clear_bones_local_pose_override() - #var distance_in_each_frame = (actual_velocity*Vector3(1,0,1)).rotated(Vector3.UP,skeleton_ref.global_transform.basis.get_euler().y).length() - #var hips = skeleton_ref.find_bone(hips_name) - #var hips_transform = skeleton_ref.get_bone_pose(hips) - # - #var hips_distance_to_ground - #var stride_scale : float = 1.0 - ##Get Bones - #var bone = skeleton_ref.find_bone(Foot) - #var bone_transform = skeleton_ref.get_bone_global_pose_no_override(bone) - # - #var thigh_bone = skeleton_ref.find_bone(Thigh) - #var thigh_transform = skeleton_ref.get_bone_global_pose_no_override(thigh_bone) - #var thigh_angle = thigh_transform.basis.get_euler().x - # - ##Calculate - #var stride_direction : Vector3 = Vector3.FORWARD # important to use in orientation warping - #var stride_warping_plane_origin = Plane(floor_normal, bone_transform.origin).intersects_ray(thigh_transform.origin,Vector3.DOWN) -## print(stride_warping_plane_origin) - #if stride_warping_plane_origin == null: - #return #Failed to get a plane origin/ we are probably in air -# - #var scale_origin = Plane(stride_direction,stride_warping_plane_origin).project(bone_transform.origin) - #var anim_speed = pow(hips_transform.origin.distance_to(bone_transform.origin),2) - pow(hips_transform.origin.y,2) - #anim_speed = sqrt(abs(anim_speed)) - #stride_scale = clampf(distance_in_each_frame/4/anim_speed,0.0,2.0) - #var foot_warped_location : Vector3 = scale_origin + (bone_transform.origin - scale_origin) * stride_scale - ## Apply - #if stride_scale > 0.1: - #target.position = lerp(target.position, foot_warped_location.rotated(Vector3.UP,mesh_ref.rotation.y), 1) - ##test - ##test_sphere.position = foot_warped_location.rotated(Vector3.UP,movement_direction) -# -# -#var updated_raycast_pos : Array[bool] -#func foot_look_at_y(from:Vector3, to:Vector3, up_ref:Vector3 = Vector3.UP) -> Basis: - #var forward = (to - from).normalized() - #var right = up_ref.normalized().cross(forward).normalized() - #forward = right.cross(up_ref).normalized() - #return Basis(right, up_ref, forward) -#func slope_warping(target:Node3D, raycast:RayCast3D, touch_raycast:RayCast3D, no_raycast_pos, leg_number:int): - #if updated_raycast_pos.size() < leg_number+1: - #updated_raycast_pos.resize(leg_number+1) -# - #if slope_warping_feet_locking_enable: - #if touch_raycast.is_colliding(): - #if updated_raycast_pos[leg_number] == false: - #raycast.global_position = no_raycast_pos.global_position + Vector3(0.0,0.25,0.0) - #updated_raycast_pos[leg_number] = true - #else: - #updated_raycast_pos[leg_number] = false - ## Update position to not let the leg yeet towards the old far location - #raycast.global_position = no_raycast_pos.global_position + Vector3(0.0,0.25,0.0) - #else: - #raycast.global_position = no_raycast_pos.global_position + Vector3(0.0,0.25,0.0) -# - #if raycast.is_colliding() and touch_raycast.is_colliding(): #if raycast is on ground - #var hit_point = raycast.get_collision_point() + Vector3.UP*slope_warping_foot_height_offset #gets Y position of where the ground is. - #target.global_transform.origin = hit_point #sets the target to the y position of the hitpoint - ##if raycast.get_collision_normal() != Vector3.UP: - #var relative_normal = hit_point * raycast.get_collision_normal() - #target.look_at(relative_normal, Vector3.UP) - #target.global_transform = _basis_from_normal(target.global_transform, raycast.get_collision_normal()) - #target.rotation += Vector3(-35, 0, 180) - #target.global_basis = foot_look_at_y(Vector3.ZERO, skeleton_ref.global_transform.basis.z, raycast.get_collision_normal()).rotated(Vector3.RIGHT, PI)#.rotated(raycast.get_collision_normal(), mesh_ref.rotation.y+PI/2) - #else: - #target.global_transform.origin = no_raycast_pos.global_transform.origin #if the raycast not colliding, the player is in the air and so the target position is set to the no_raycast_pos func _physics_process(delta): #Debug() @@ -382,6 +315,8 @@ func _physics_process(delta): Global.movement_state.none: pass Global.movement_state.grounded: + pose_warping.stride_warping_enable = true + pose_warping.slope_warping_enable = true #------------------ Rotate Character Mesh ------------------# match movement_action: Global.movement_action.none: @@ -390,6 +325,10 @@ func _physics_process(delta): if (is_moving and input_is_moving) or (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 0.5: smooth_character_rotation(actual_velocity,calc_grounded_rotation_rate(),delta) Global.rotation_mode.looking_direction: + if gait != Global.gait.sprinting: + pose_warping.orientation_warping_enable = true + else: + pose_warping.orientation_warping_enable = false if (is_moving and input_is_moving) or (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 0.5: smooth_character_rotation(-camera_root.HObject.transform.basis.z if gait != Global.gait.sprinting else actual_velocity,calc_grounded_rotation_rate(),delta) rotate_in_place_check() @@ -402,14 +341,17 @@ func _physics_process(delta): smooth_character_rotation(input_acceleration ,2.0,delta) Global.movement_state.in_air: + pose_warping.stride_warping_enable = false + pose_warping.slope_warping_enable = false #------------------ Rotate Character Mesh In Air ------------------# - match rotation_mode: - Global.rotation_mode.velocity_direction: - smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) - Global.rotation_mode.looking_direction: - smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) - Global.rotation_mode.aiming: - smooth_character_rotation(-camera_root.HObject.transform.basis.z ,15.0,delta) + if mantle_component and !mantle_component.is_climbing: + match rotation_mode: + Global.rotation_mode.velocity_direction: + smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) + Global.rotation_mode.looking_direction: + smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) + Global.rotation_mode.aiming: + smooth_character_rotation(-camera_root.HObject.transform.basis.z ,15.0,delta) #------------------ Mantle Check ------------------# if input_is_moving == true: mantle_check() @@ -423,8 +365,14 @@ func _physics_process(delta): #------------------ Gravity ------------------# if is_flying == false and character_node is CharacterBody3D: - character_node.velocity.y = lerp(character_node.velocity.y,vertical_velocity.y - character_node.get_floor_normal().y,delta * gravity) - character_node.move_and_slide() + if mantle_component: + if !mantle_component.is_climbing: + character_node.velocity.y = lerp(character_node.velocity.y,vertical_velocity.y - character_node.get_floor_normal().y,delta * gravity) + character_node.move_and_slide() + else: + character_node.velocity.y = lerp(character_node.velocity.y,vertical_velocity.y - character_node.get_floor_normal().y,delta * gravity) + character_node.move_and_slide() + if ground_check.is_colliding() and is_flying == false: movement_state = Global.movement_state.grounded else: @@ -432,6 +380,7 @@ func _physics_process(delta): movement_state = Global.movement_state.in_air if character_node is CharacterBody3D: vertical_velocity += Vector3.DOWN * gravity * delta + if character_node is CharacterBody3D and character_node.is_on_ceiling(): vertical_velocity.y = 0 #------------------ Stair climb ------------------# @@ -556,6 +505,8 @@ var PrevVelocity :Vector3 ## Adds input to move the character, should be called when Idle too, to execute deacceleration for CharacterBody3D or reset velocity for RigidBody3D. ## when Idle speed and direction should be passed as 0, and deacceleration passed, or leave them empty. func add_movement_input(direction: Vector3 = Vector3.ZERO, Speed: float = 0, Acceleration: float = deacceleration if character_node is CharacterBody3D else 0) -> void: + if mantle_component and mantle_component.is_climbing: + return var max_speed : float = Speed input_direction = direction @@ -615,7 +566,8 @@ func calc_animation_data(): # it is used to modify the animation data to get the func mantle_check(): - pass + if mantle_component: + mantle_component.detect_ledge() func jump() -> void: if ground_check.is_colliding() and not head_bonked: diff --git a/addons/AMSG/Components/MantleComponent/MantleComponent.gd b/addons/AMSG/Components/MantleComponent/MantleComponent.gd new file mode 100644 index 0000000..ecfdccc --- /dev/null +++ b/addons/AMSG/Components/MantleComponent/MantleComponent.gd @@ -0,0 +1,65 @@ +@tool +extends Node3D +class_name MantleComponent +@export var character_collision_shape : CollisionShape3D +@export var character_node : PhysicsBody3D +@export var animation_tree : AnimationTree +@export var mantle_anim : String = "Mantle" +#@export var character_height : float = 1.75 +@onready var ledge_top_detect : RayCast3D = $LedgeTopDetect +@onready var ledge_detect : RayCast3D = $LedgeDetect +@onready var shape_cast_3d = $ShapeCast3D +@onready var ledge_ground_detect = $LedgeGroundDetect + +var is_climbing : bool + +func _get_configuration_warnings(): + if not get_parent() is Skeleton3D: + return ["Parent Must be Skeleton3D."] + +func _ready(): + if not get_parent() is Skeleton3D: + assert(false, "Parent Must be Skeleton3D.") + update_configuration_warnings() + if not character_node is CharacterBody3D and not character_node is RigidBody3D: + assert(false, "Character Node Must be either CharacterBody3D or RigidBody3D, please choose the right node from the inspector.") + shape_cast_3d.shape = character_collision_shape.shape + #shape_cast_3d.position = character_collision_shape.position + shape_cast_3d.add_exception(character_node) + ledge_top_detect.add_exception(character_node) + ledge_detect.add_exception(character_node) + ledge_ground_detect.add_exception(character_node) +func _physics_process(delta): + ledge_detect.position.y = shape_cast_3d.shape.height#character_height + ledge_top_detect.position.y = shape_cast_3d.shape.height + 0.25#character_height + 0.25 + ledge_ground_detect.position.y = ledge_top_detect.position.y + ledge_ground_detect.position.z = 1 + ledge_detect.rotation_degrees.x = -90 + ledge_top_detect.rotation_degrees.x = -90 +func detect_ledge(): + if is_climbing: + return + if ledge_detect.is_colliding() and ledge_ground_detect.is_colliding() and !ledge_top_detect.is_colliding(): + shape_cast_3d.global_position = shape_cast_3d.shape.height/2*Vector3.UP + Vector3(0,0.1,0) + ledge_ground_detect.get_collision_point() + if !shape_cast_3d.is_colliding(): #The character can fit into the mantle location, Climb + mantle() + + +func mantle(): + is_climbing = true + if character_node is RigidBody3D: + character_node.freeze_mode = RigidBody3D.FREEZE_MODE_STATIC + if character_node is CharacterBody3D: + character_node.velocity = Vector3.ZERO + character_node.move_and_slide() + animation_tree.active = false + + var anim_player : AnimationPlayer = get_node(String(animation_tree.get_path()) + "/" + String(animation_tree.anim_player)) + anim_player.connect("animation_finished", func(anim):\ + character_node.global_position = shape_cast_3d.global_position;\ + animation_tree.active = true;\ + await get_tree().create_timer(0.1).timeout;\ + is_climbing = false + ) + anim_player.play(mantle_anim) + diff --git a/addons/AMSG/Components/MantleComponent/MantleComponent.tscn b/addons/AMSG/Components/MantleComponent/MantleComponent.tscn new file mode 100644 index 0000000..8009045 --- /dev/null +++ b/addons/AMSG/Components/MantleComponent/MantleComponent.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=3 format=3 uid="uid://dpniuhmc5sj82"] + +[ext_resource type="Script" path="res://addons/AMSG/Components/MantleComponent/MantleComponent.gd" id="1_ix4sf"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_70w0s"] +resource_local_to_scene = true +radius = 0.375 +height = 1.75 + +[node name="MantleComponent" type="Node3D"] +script = ExtResource("1_ix4sf") +mantle_anim = "Kick" + +[node name="ShapeCast3D" type="ShapeCast3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +top_level = true +shape = SubResource("CapsuleShape3D_70w0s") +target_position = Vector3(0, 0, 0) + +[node name="LedgeTopDetect" type="RayCast3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 2, 0) + +[node name="LedgeDetect" type="RayCast3D" parent="."] +transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.75, 0) + +[node name="LedgeGroundDetect" type="RayCast3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 1) diff --git a/addons/PoseWarping/PoseWarping.gd b/addons/PoseWarping/PoseWarping.gd index a677bdd..5af883e 100644 --- a/addons/PoseWarping/PoseWarping.gd +++ b/addons/PoseWarping/PoseWarping.gd @@ -1,5 +1,5 @@ @tool -extends Node +extends Node3D class_name PoseWarping ## a Node that Handles Pose Warping for character for enhanced animations ## Must be a child of Skeleton3D @@ -56,11 +56,11 @@ class_name PoseWarping @onready var slope_warping_raycast_right : RayCast3D = $RightLegRayCast @onready var slope_warping_bone_attachment_right_foot : BoneAttachment3D = $RightFootAttachment @export var slope_warping_foot_height_offset : float = 0.1 -#func _init(_character_node:PhysicsBody3D, _skeleton:Skeleton3D, _LeftLegIK:SkeletonIK3D, _RightLegIK:SkeletonIK3D): - #character_node = _character_node - #character_skeleton = _skeleton - #LeftLegIK = _LeftLegIK - #RightLegIK = _RightLegIK + + + +@onready var left_magnet = $LeftMagnet +@onready var right_magnet = $RightMagnet func _get_configuration_warnings(): if not get_parent() is Skeleton3D: @@ -91,6 +91,8 @@ func _ready(): func _process(delta): #if Engine.is_editor_hint(): #return + RightLegIK.magnet = right_magnet.position.rotated(Vector3.UP, orientation_direction) + LeftLegIK.magnet = left_magnet.position.rotated(Vector3.UP, orientation_direction) if stride_warping_enable or slope_warping_enable: var bone_transform_left = character_skeleton.get_bone_global_pose_no_override(character_skeleton.find_bone(String(LeftLegIK.tip_bone))) var bone_transform_right = character_skeleton.get_bone_global_pose_no_override(character_skeleton.find_bone(String(RightLegIK.tip_bone))) @@ -112,9 +114,13 @@ func _process(delta): if slope_warping_enable: slope_warping(LeftLegIKTarget, slope_warping_raycast_left, slope_warping_raycast_left_touch_detection, slope_warping_bone_attachment_left_foot, 0) slope_warping(RightLegIKTarget, slope_warping_raycast_right, slope_warping_raycast_right_touch_detection, slope_warping_bone_attachment_right_foot, 1) + + orientation_warping(orientation_warping_enable, orientation_warping_camera_h_object, character_velocity, character_skeleton, hips_bone_name, orientation_warping_spine_bones_names, orientation_warping_offset, delta, orientation_warping_turn_rate) if orientation_warping_enable: - #var orientation_warping_condition = rotation_mode != Global.rotation_mode.velocity_direction and movement_state == Global.movement_state.grounded and movement_action == Global.movement_action.none and gait != Global.gait.sprinting and input_is_moving - orientation_warping(true, orientation_warping_camera_h_object, character_velocity, character_skeleton, hips_bone_name, orientation_warping_spine_bones_names, 0.0, delta) + rotation.y = orientation_direction + else: + orientation_direction = 0 + rotation.y = 0 @@ -171,7 +177,7 @@ func orientation_warping(enabled:bool,CameraObject, Velocity:Vector3, character_ set_bone_y_rotation(character_skeleton,Hip,orientation_direction) for bone in Spines: - set_bone_y_rotation(character_skeleton,bone,(-orientation_direction/(Spines.size()))+Offset) + set_bone_y_rotation(character_skeleton,bone,(orientation_direction/(Spines.size()))+Offset) func set_bone_y_rotation(skeleton:Skeleton3D,bone_name:String, y_rot:float, presistant:bool=true): @@ -242,11 +248,16 @@ func slope_warping(target:Node3D, raycast:RayCast3D, touch_raycast:RayCast3D, no if raycast.is_colliding() and (touch_raycast.is_colliding() or character_velocity.length()<1.0): #if raycast is on ground var hit_point = raycast.get_collision_point() + Vector3.UP*slope_warping_foot_height_offset #gets Y position of where the ground is. target.global_transform.origin = hit_point #sets the target to the y position of the hitpoint - #if raycast.get_collision_normal() != Vector3.UP: + var up_ref = raycast.get_collision_normal() + #if up_ref != Vector3.UP: + #var forward = (character_skeleton.global_transform.basis.z).normalized() + #var right = up_ref.normalized().cross(forward).normalized() + #forward = right.cross(up_ref).normalized() + #target.rotate(Vector3.RIGHT, forward.angle_to(target.global_transform.basis.y)) #var relative_normal = hit_point * raycast.get_collision_normal() - #target.look_at(relative_normal, Vector3.UP) + #target.global_transform = _basis_from_normal(target.global_transform, raycast.get_collision_normal()) #target.rotation += Vector3(-35, 0, 180) - #target.global_transform.basis = foot_look_at_y(Vector3.ZERO, character_skeleton.global_transform.basis.z, raycast.get_collision_normal()) + #target.global_transfyouorm.basis = foot_look_at_y(Vector3.ZERO, character_skeleton.global_transform.basis.z, raycast.get_collision_normal()) #else: #raycast.global_transform.origin = target.global_transform.origin #if the raycast not colliding, the player is in the air and so the target position is set to the no_raycast_pos diff --git a/addons/PoseWarping/PoseWarping.tscn b/addons/PoseWarping/PoseWarping.tscn index 1b6556d..f1f88ff 100644 --- a/addons/PoseWarping/PoseWarping.tscn +++ b/addons/PoseWarping/PoseWarping.tscn @@ -64,3 +64,9 @@ debug_shape_thickness = 5 [node name="RightLegRayCast" type="RayCast3D" parent="."] top_level = true debug_shape_thickness = 5 + +[node name="LeftMagnet" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 1, 1) + +[node name="RightMagnet" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.999999, 0, 0, 0, 1, -0.25, 1, 1)