diff options
-rw-r--r-- | CreepyRobots.csproj | 3 | ||||
-rw-r--r-- | _ActiveRagdoll/Balance.cs | 42 | ||||
-rw-r--r-- | _Debug/REPL.cs | 14 |
3 files changed, 38 insertions, 21 deletions
diff --git a/CreepyRobots.csproj b/CreepyRobots.csproj index 4b2362c..4a8859f 100644 --- a/CreepyRobots.csproj +++ b/CreepyRobots.csproj @@ -183,4 +183,7 @@ <ItemGroup> <Folder Include="_ActiveRagdoll\Actions\" /> </ItemGroup> + <Target Name="PostBuild" AfterTargets="PostBuildEvent"> + <Exec Command="D:\Documents\Unity\Decompile\CreepyRobots\copy_dll.cmd" /> + </Target> </Project>
\ No newline at end of file diff --git a/_ActiveRagdoll/Balance.cs b/_ActiveRagdoll/Balance.cs index 06953fa..f034290 100644 --- a/_ActiveRagdoll/Balance.cs +++ b/_ActiveRagdoll/Balance.cs @@ -1,6 +1,6 @@ using UnityEngine; -//Player Balance 动作-控制身体平衡 +//Player Balance 动作-控制双脚的位置,让双脚和双脚的中点尽可能和重心在水平的投影重合 public class Balance : MonoBehaviour { #region rigs @@ -66,6 +66,7 @@ public class Balance : MonoBehaviour } } + // 让双脚尽量靠近重心的水平投影 private void CenterLegs() { Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; @@ -84,6 +85,7 @@ public class Balance : MonoBehaviour } } + // 让双脚的中点尽量和重心的水平投影重合 private void BalanceLegs() { Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f; @@ -92,25 +94,37 @@ public class Balance : MonoBehaviour Vector3 pos = vector3; pos.y += 0.3f; + Vector3 vector03 = vector3; if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y)) { vector3.y = 0f; Vector3 vector4 = centerOfMass - vector3; // centerOfMass是xoz平面,不含y - REPL.footCenter.GetComponent<DebugRigidBody>().customDraw = () => - { - Draw.Sphere(vector, 0.05f); - Draw.Sphere(vector2, 0.05f); - Draw.Sphere(pos, 0.05f); - Draw.Sphere(vector3, 0.05f); - Draw.Sphere(hip.worldCenterOfMass, 0.2f); - - Draw.Sphere(centerOfMass, 0.05f); - Draw.Line3D(vector3 + new Vector3(0, footLeft.transform.position.y, 0), centerOfMass + new Vector3(0, footLeft.transform.position.y, 0)); - }; + + REPL.footCenter.GetComponent<DebugRigidBody>().customDraw = () => + { + //return; + + Draw.Sphere(vector, 0.05f); + Draw.Sphere(vector2, 0.05f); + + Draw.color = Color.red; + Draw.Sphere(pos, 0.05f); + Draw.Sphere(vector03, 0.05f); + Draw.color = Color.white; + + Draw.Sphere(hip.worldCenterOfMass, 0.2f); + + Draw.Sphere(centerOfMass, 0.05f); + + Draw.color = Color.green; + Draw.Line3D(vector, vector + vector4); + Draw.Line3D(vector2, vector2 + vector4); + Draw.color = Color.white; + }; footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration); - footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration); - } + footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration); + }; } } diff --git a/_Debug/REPL.cs b/_Debug/REPL.cs index 8195a56..5dd99e4 100644 --- a/_Debug/REPL.cs +++ b/_Debug/REPL.cs @@ -128,13 +128,13 @@ class REPL public static void AddHeightBox() { - float height = 2; - GameObject cube = new GameObject(); - cube.transform.position = new Vector3(4.39f, 31.397f + height / 2.0f, -9.96f); - var drb = cube.AddComponent<DebugRigidBody>(); - drb.mode = DebugRigidBody.EMode.Cube; - drb.color = UnityEngine.Color.red; - drb.cubeLen = height; + //float height = 2; + //GameObject cube = new GameObject(); + //cube.transform.position = new Vector3(4.39f, 31.397f + height / 2.0f, -9.96f); + //var drb = cube.AddComponent<DebugRigidBody>(); + //drb.mode = DebugRigidBody.EMode.Cube; + //drb.color = UnityEngine.Color.red; + //drb.cubeLen = height; } public static void AddFootCenter() |