summaryrefslogtreecommitdiff
path: root/_ActiveRagdoll
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-15 21:03:07 +0800
committerchai <215380520@qq.com>2024-03-15 21:03:07 +0800
commit78304183fb59e243a2d6da4a00a4311ae21c9717 (patch)
treeaeae48561b9a5c25a1d58de28b8b3e2af37598e4 /_ActiveRagdoll
parentdbba1ae118a70db8be668806c0af8655e7b4afe7 (diff)
*misc
Diffstat (limited to '_ActiveRagdoll')
-rw-r--r--_ActiveRagdoll/Balance.cs47
-rw-r--r--_ActiveRagdoll/Holding.cs1
-rw-r--r--_ActiveRagdoll/Player/AnimationHandler.cs (renamed from _ActiveRagdoll/AnimationHandler.cs)3
-rw-r--r--_ActiveRagdoll/Player/MovementDataHandler.cs (renamed from _ActiveRagdoll/MovementDataHandler.cs)0
-rw-r--r--_ActiveRagdoll/Player/MovementHandler.cs (renamed from _ActiveRagdoll/MovementHandler.cs)1
-rw-r--r--_ActiveRagdoll/Player/PickupHandler.cs (renamed from _ActiveRagdoll/PickupHandler.cs)3
-rw-r--r--_ActiveRagdoll/Standing.cs4
7 files changed, 40 insertions, 19 deletions
diff --git a/_ActiveRagdoll/Balance.cs b/_ActiveRagdoll/Balance.cs
index dc9ae60..06953fa 100644
--- a/_ActiveRagdoll/Balance.cs
+++ b/_ActiveRagdoll/Balance.cs
@@ -1,32 +1,31 @@
using UnityEngine;
+//Player Balance 动作-控制身体平衡
public class Balance : MonoBehaviour
{
- private Rigidbody handLeft;
-
+ #region rigs
+ private Rigidbody handLeft;
private Rigidbody handRight;
-
- private Rigidbody footLeft;
-
- private Rigidbody footRight;
-
+ private Rigidbody footLeft; // kneeLeft
+ private Rigidbody footRight; // kneeRight
private Rigidbody hip;
+ #endregion
- private Vector3 centerOfMass;
+ private Vector3 centerOfMass; // 5.0759, 0, -7.2038
- private Rigidbody[] allRigs;
+ private Rigidbody[] allRigs;//所有14个parts
- public float[] balanceForce;
+ public float[] balanceForce; // 50 30 30 30
- public float[] footCenterForces;
+ public float[] footCenterForces; // 50 20 20 20
- private AnimationHandler animationHandler;
+ private AnimationHandler animationHandler; // 当前动作编号
private PlayerDeath death;
private Strength str;
- private float muscleMultiplier;
+ private float muscleMultiplier; // 1
private void Start()
{
@@ -90,11 +89,27 @@ public class Balance : MonoBehaviour
Vector3 vector = footLeft.transform.position + footLeft.transform.forward * 0.5f;
Vector3 vector2 = footRight.transform.position + footRight.transform.forward * 0.5f;
Vector3 vector3 = (vector + vector2) / 2f;
- if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y))
+
+ Vector3 pos = vector3;
+ pos.y += 0.3f;
+
+ if (!(vector3.y + 0.3f > hip.worldCenterOfMass.y))
{
vector3.y = 0f;
- Vector3 vector4 = centerOfMass - vector3;
- footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration);
+ 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));
+ };
+
+ footLeft.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector, ForceMode.Acceleration);
footRight.AddForceAtPosition(vector4 * muscleMultiplier * balanceForce[animationHandler.animationState], vector2, ForceMode.Acceleration);
}
}
diff --git a/_ActiveRagdoll/Holding.cs b/_ActiveRagdoll/Holding.cs
index dafc08b..eb27095 100644
--- a/_ActiveRagdoll/Holding.cs
+++ b/_ActiveRagdoll/Holding.cs
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+//Player Holding 动作-拿武器
public class Holding : MonoBehaviour
{
[HideInInspector]
diff --git a/_ActiveRagdoll/AnimationHandler.cs b/_ActiveRagdoll/Player/AnimationHandler.cs
index 6011e47..382b3a5 100644
--- a/_ActiveRagdoll/AnimationHandler.cs
+++ b/_ActiveRagdoll/Player/AnimationHandler.cs
@@ -1,8 +1,9 @@
using UnityEngine;
+//Player AnimationHandler 记录当前动作状态编号
public class AnimationHandler : MonoBehaviour
{
- public int animationState;
+ public int animationState;
private void Start()
{
diff --git a/_ActiveRagdoll/MovementDataHandler.cs b/_ActiveRagdoll/Player/MovementDataHandler.cs
index 18d43f5..18d43f5 100644
--- a/_ActiveRagdoll/MovementDataHandler.cs
+++ b/_ActiveRagdoll/Player/MovementDataHandler.cs
diff --git a/_ActiveRagdoll/MovementHandler.cs b/_ActiveRagdoll/Player/MovementHandler.cs
index 22795f7..4579efc 100644
--- a/_ActiveRagdoll/MovementHandler.cs
+++ b/_ActiveRagdoll/Player/MovementHandler.cs
@@ -1,6 +1,7 @@
using System.Collections;
using UnityEngine;
+//Player MovementHandler 控制移动、跳跃
public class MovementHandler : MonoBehaviour
{
private InputHandler inputHandler;
diff --git a/_ActiveRagdoll/PickupHandler.cs b/_ActiveRagdoll/Player/PickupHandler.cs
index 8bf1615..6a3a249 100644
--- a/_ActiveRagdoll/PickupHandler.cs
+++ b/_ActiveRagdoll/Player/PickupHandler.cs
@@ -1,5 +1,6 @@
using UnityEngine;
+//Player PickupHandler 捡武器
public class PickupHandler : MonoBehaviour
{
public Pickup setWeapon;
@@ -8,7 +9,7 @@ public class PickupHandler : MonoBehaviour
private WeaponHandler weaponHandler;
- private Holding holding;
+ private Holding holding; // holding动作
private float counter;
diff --git a/_ActiveRagdoll/Standing.cs b/_ActiveRagdoll/Standing.cs
index afbfd8b..2af0e4b 100644
--- a/_ActiveRagdoll/Standing.cs
+++ b/_ActiveRagdoll/Standing.cs
@@ -1,8 +1,9 @@
using UnityEngine;
+//Player Standing 动作-站立
public class Standing : MonoBehaviour
{
- public RigidbodyMovment[] rigsToLift;
+ public RigidbodyMovment[] rigsToLift; //Head, Torso
public AnimationCurve[] animationLiftCurves;
@@ -49,6 +50,7 @@ public class Standing : MonoBehaviour
RigidbodyMovment[] array = rigsToLift;
foreach (RigidbodyMovment rigidbodyMovment in array)
{
+ // 施加一个向上的力
rigidbodyMovment.rig.AddForce(Vector3.up * muscleMultiplier * rigidbodyMovment.force * legAngleMultiplier * curve.Evaluate(standingData.distanceToGround + offset + moveData.slopeVelocityStrenght * -0.2f), ForceMode.Acceleration);
}
}