diff options
author | chai <215380520@qq.com> | 2024-04-15 21:05:01 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-04-15 21:05:01 +0800 |
commit | 0464810f2f83c86560c3422d664380d474cb3e56 (patch) | |
tree | 3548bec2d39f6e2a9803dd02dd2f636922ea07c7 | |
parent | f34c222b242c6fd01ed209ff827c614621160048 (diff) |
*misc
9 files changed, 213 insertions, 63 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Prefabs/human_rigging.prefab b/ActiveRagdoll/Assets/TABG/Prefabs/human_rigging.prefab index 850bb69..6bbf404 100644 --- a/ActiveRagdoll/Assets/TABG/Prefabs/human_rigging.prefab +++ b/ActiveRagdoll/Assets/TABG/Prefabs/human_rigging.prefab @@ -1127,6 +1127,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0152a635e0b8d6547a566f7d1d7f34f8, type: 3} m_Name: m_EditorClassIdentifier: + animationStates: [] + animationState: 0 --- !u!114 &8431171258552371941 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2232,6 +2234,7 @@ GameObject: m_Component: - component: {fileID: 1666344766112317020} - component: {fileID: 8128778564773403802} + - component: {fileID: 368451398} m_Layer: 6 m_Name: human_rigging m_TagString: Untagged @@ -2280,6 +2283,7 @@ MonoBehaviour: body: {fileID: 0} step: {fileID: 0} strength: {fileID: 0} + animation: {fileID: 0} actions: standing: {fileID: 0} movement: {fileID: 0} @@ -2300,6 +2304,20 @@ MonoBehaviour: legLeft: {fileID: 0} legRight: {fileID: 0} torso: {fileID: 0} + input: {fileID: 0} +--- !u!114 &368451398 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2047971321291531494} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3e4f01fcb88b28040a13a524b623a670, type: 3} + m_Name: + m_EditorClassIdentifier: + allowStrafe: 1 --- !u!1 &2132482246703060397 GameObject: m_ObjectHideFlags: 0 diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs index 9a87817..073ecbd 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/MovementDataHandler.cs @@ -1,3 +1,6 @@ +using Rigging.BodyPart; +using Rigging.Debugging; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -6,16 +9,48 @@ namespace Rigging.Data { public class MovementDataHandler : RiggingDataBase { - // Start is called before the first frame update - void Start() + + [HideInInspector, NonSerialized] + public Vector3 groundedForward; + + [HideInInspector, NonSerialized] + public Vector3 right; + + [HideInInspector, NonSerialized] + public Vector3 left; + + [HideInInspector, NonSerialized] + public Vector3 groundedBack; + + [HideInInspector, NonSerialized] + public float sinceJump = 1f; + + [HideInInspector, NonSerialized] + public float slopeStrenght; + + public Transform rotationTarget; + + private Rigging.BodyPart.Hip hip; + + protected override void OnStart() { - + base.OnStart(); + + hip = player.body.hip; } - // Update is called once per frame - void Update() + private void Update() { - + sinceJump += Time.deltaTime; + groundedForward = rotationTarget.forward; + groundedForward.y = slopeStrenght * 1f; + groundedForward = groundedForward.normalized; + groundedBack = -groundedForward; + right = rotationTarget.right; + left = -rotationTarget.right; + slopeStrenght = Mathf.Lerp(slopeStrenght, 0f, Time.deltaTime * 1f); + + GLHandle.DrawLine(hip.transform.position, hip.transform.position + groundedForward * 10f); } } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs index 2afef1d..3a90eb6 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/SetAnimationByInput.cs @@ -5,9 +5,10 @@ using UnityEngine; namespace Rigging.Data { + [DisallowMultipleComponent] public class SetAnimationByInput : RiggingDataBase { - private InputHandler input; + private Rigging.Inputs.InputHandler input; private AnimationHandler anim; @@ -15,14 +16,32 @@ namespace Rigging.Data protected override void OnStart() { - input = player.status.input; + input = player.input; anim = player.status.animation; standingData = player.status.standingData; } private void Update() { - + if ((double)standingData.sinceGrounded > 0.2) + { + anim.animationState = 3; // jump + } + else if (input.inputMovementDirection.magnitude > 0.1f) + { + if (input.isSpringting) + { + anim.animationState = 1; // sprint + } + else + { + anim.animationState = 2; // run + } + } + else + { + anim.animationState = 0; // stand + } } } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs index 7e673b1..e04ff0d 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs @@ -31,7 +31,7 @@ namespace Rigging.Data { leftLeg = player.body.legLeft.transform; rightLeg = player.body.legRight.transform; -// animationHandler = GetComponent<AnimationHandler>(); + animationHandler = player.status.animation; hip = player.body.hip.transform; } } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs index bae645b..d32d67d 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs @@ -1,18 +1,60 @@ +using Rigging.Camera; +using Rigging.Data; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Rendering; -public class InputHandler : MonoBehaviour +namespace Rigging.Inputs { - // Start is called before the first frame update - void Start() - { - - } - // Update is called once per frame - void Update() + public class InputHandler : MonoBehaviour { - + public Vector3 inputMovementDirection; + + public Vector3 lastInputDirection; + + public bool allowStrafe = true; + + private MovementDataHandler movementData; + + public bool isSpringting = false; + + private void Start() + { + movementData = GetComponentInChildren<MovementDataHandler>(); + } + + private void Update() + { + inputMovementDirection = Vector3.zero; + if (Input.GetKey(KeyCode.W)) + { + inputMovementDirection += movementData.groundedForward; + } + if (Input.GetKey(KeyCode.S)) + { + inputMovementDirection += movementData.groundedBack; + } + if (Input.GetKey(KeyCode.D) && allowStrafe) + { + inputMovementDirection += movementData.right; + } + if (Input.GetKey(KeyCode.A) && allowStrafe) + { + inputMovementDirection += movementData.left; + } + //if (Input.GetKey(KeyCode.LeftShift) && (!cameraMovement || !cameraMovement.ADS)) + //{ + // isSpringting = true; + //} + if (inputMovementDirection != Vector3.zero) + { + lastInputDirection = inputMovementDirection; + } + } + } + } diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs b/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs deleted file mode 100644 index 0f0feab..0000000 --- a/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class SetAnimationByInput : MonoBehaviour -{ - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs.meta deleted file mode 100644 index 5f4a2de..0000000 --- a/ActiveRagdoll/Assets/TABG/Scripts/Input/SetAnimationByInput.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 01e4ef433b714c844acfa85d61aa6921 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Player.cs b/ActiveRagdoll/Assets/TABG/Scripts/Player.cs index b2168df..e07da7f 100644 --- a/ActiveRagdoll/Assets/TABG/Scripts/Player.cs +++ b/ActiveRagdoll/Assets/TABG/Scripts/Player.cs @@ -6,6 +6,7 @@ using Rigging.Action; using Rigging.Camera; using System; using Rigging.BodyPart; +using Rigging.Inputs; namespace Rigging { @@ -25,8 +26,6 @@ namespace Rigging public Strength strength; - public InputHandler input; - public AnimationHandler animation; } @@ -71,6 +70,8 @@ namespace Rigging public BodyParts body; + public Rigging.Inputs.InputHandler input; + private void Awake() { status = new Status(); @@ -80,7 +81,6 @@ namespace Rigging status.body = GetComponentInChildren<RigidbodyHolder>(); status.step = GetComponentInChildren<StepHandler>(); status.strength = GetComponentInChildren<Strength>(); - status.input = GetComponentInChildren<InputHandler>(); status.animation = GetComponentInChildren<AnimationHandler>(); actions = new Actions(); @@ -105,6 +105,8 @@ namespace Rigging body.legRight = GetComponentInChildren<Rigging.BodyPart.LegRight>(); body.torso = GetComponentInChildren<Rigging.BodyPart.Torso>(); + input = GetComponent<Rigging.Inputs.InputHandler>(); + } } diff --git a/ActiveRagdoll/Assets/TABG/Test.unity b/ActiveRagdoll/Assets/TABG/Test.unity index 81f2617..d62c16f 100644 --- a/ActiveRagdoll/Assets/TABG/Test.unity +++ b/ActiveRagdoll/Assets/TABG/Test.unity @@ -280,7 +280,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &705806567 GameObject: @@ -378,7 +378,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &814323549 GameObject: @@ -475,7 +475,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &981251352 GameObject: @@ -570,7 +570,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!114 &981251355 MonoBehaviour: @@ -592,6 +592,24 @@ MonoBehaviour: m_ShadowLayerMask: 1 m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} +--- !u!1 &1549273951 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1808858621, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + m_PrefabInstance: {fileID: 8128778564773403800} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1549273962 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1549273951} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a7459e71d3133e747833a399f4895b51, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1848931106 GameObject: m_ObjectHideFlags: 0 @@ -670,13 +688,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1848931106} - m_LocalRotation: {x: 0.14744055, y: 0.41793463, z: -0.068966135, w: 0.89377606} - m_LocalPosition: {x: -3.688255, y: 2.6339426, z: -2.137497} + m_LocalRotation: {x: 0.17066039, y: -0.4875977, z: 0.09782282, w: 0.8506199} + m_LocalPosition: {x: 2.20858, y: 2.5698051, z: -1.10273} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1848931110 MonoBehaviour: @@ -685,7 +703,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1848931106} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 795911e4559bdc649bea6a391e6aef71, type: 3} m_Name: @@ -823,7 +841,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &543450652995596035 Transform: @@ -839,7 +857,7 @@ Transform: m_Children: - {fileID: 3078023919892016089} m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &919132148792948153 GameObject: @@ -1034,7 +1052,7 @@ PrefabInstance: - target: {fileID: 1666344766112317020, guid: fce18bbf37be1384eb1a089a94aac81d, type: 3} propertyPath: m_RootOrder - value: 6 + value: 5 objectReference: {fileID: 0} - target: {fileID: 1666344766112317020, guid: fce18bbf37be1384eb1a089a94aac81d, type: 3} @@ -1091,6 +1109,51 @@ PrefabInstance: propertyPath: m_Name value: human_rigging objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.size + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[1].theInt + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[2].theInt + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[3].theInt + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[0].theString + value: Stand + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[1].theString + value: Sprint + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[2].theString + value: Run + objectReference: {fileID: 0} + - target: {fileID: 7263518919066683589, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: animationStates.Array.data[3].theString + value: Jump + objectReference: {fileID: 0} + - target: {fileID: 7846447219259762999, guid: fce18bbf37be1384eb1a089a94aac81d, + type: 3} + propertyPath: rotationTarget + value: + objectReference: {fileID: 5240332616388624504} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: fce18bbf37be1384eb1a089a94aac81d, type: 3} --- !u!1001 &8277099497161960097 @@ -1103,7 +1166,7 @@ PrefabInstance: - target: {fileID: 8454544435054491251, guid: c21b1754a609d0b409dd8c8e90321803, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 8454544435054491251, guid: c21b1754a609d0b409dd8c8e90321803, type: 3} |