summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/TABG/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts')
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs4
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Action/Rotation.cs71
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs33
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs20
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraMovement.cs108
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs10
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs4
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs22
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs24
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs.meta11
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs2
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Player.cs2
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs126
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs.meta11
18 files changed, 473 insertions, 19 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
index a15d114..ee7c182 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Balance.cs
@@ -29,12 +29,8 @@ namespace Rigging.Action
public AnimationParam<float> balanceForces;
- //public float balanceForce; //50
-
public AnimationParam<float> footCenterForces;
- //public float footCenterForces;//100
-
private float muscleMultiplier; //1
private float crouchMultiplier = 1f; //1
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Action/Rotation.cs b/ActiveRagdoll/Assets/TABG/Scripts/Action/Rotation.cs
index 9652670..90515d7 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Action/Rotation.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Action/Rotation.cs
@@ -1,3 +1,5 @@
+using Rigging.BodyPart;
+using Rigging.Inputs;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -7,17 +9,74 @@ namespace Rigging.Action
public class Rotation : RiggingActionBase
{
- // Start is called before the first frame update
- void Start()
+
+ public Transform rotationTarget;
+
+ public Rigidbody hip;
+
+ public Rigidbody torso;
+
+ public Rigidbody head;
+
+ public float rotationTorque;
+
+ public float clamp;
+
+ public InputHandler input;
+
+ //private PlayerDeath death;
+
+ [HideInInspector]
+ public float hipCorrectionAmount;
+
+ public bool useHip = true;
+
+ public bool useTorso = true;
+
+ public bool useHead = true;
+
+ protected override void OnStart()
{
-
+ //death = GetComponent<PlayerDeath>();
+ rotationTarget = transform.root.GetComponentInChildren<RotationTarget>().transform;
+ hip = player.body.hip.rigidbody;
+ torso = player.body.torso.rigidbody;
+ head = player.body.head.rigidbody;
+ input = transform.root.GetComponentInChildren<InputHandler>();
}
- // Update is called once per frame
- void Update()
+ protected override void OnFixedUpdate()
{
-
+ float num = head.transform.InverseTransformPoint(rotationTarget.position).x;
+ float num2 = torso.transform.InverseTransformPoint(rotationTarget.position).x;
+ hipCorrectionAmount = hip.transform.InverseTransformPoint(hip.transform.position + input.lastInputDirection * 10f).x;
+ //float muscleFunction = death.muscleFunction;
+ float muscleFunction = 1;
+ float num3 = 0.3f;
+ if (input.inputMovementDirection.magnitude > 0.1f)
+ {
+ num3 = 1f;
+ }
+ if (clamp != 0f)
+ {
+ hipCorrectionAmount = Mathf.Clamp(hipCorrectionAmount, 0f - clamp, clamp);
+ num = Mathf.Clamp(num, 0f - clamp, clamp);
+ num2 = Mathf.Clamp(num2, 0f - clamp, clamp);
+ }
+ if (useHip)
+ {
+ hip.AddTorque(Vector3.up * muscleFunction * rotationTorque * num3 * hipCorrectionAmount, ForceMode.Acceleration);
+ }
+ if (useTorso)
+ {
+ torso.AddTorque(Vector3.up * muscleFunction * rotationTorque * num2, ForceMode.Acceleration);
+ }
+ if (useHead)
+ {
+ head.AddTorque(Vector3.up * muscleFunction * rotationTorque * num, ForceMode.Acceleration);
+ }
}
+
}
} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs b/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs
new file mode 100644
index 0000000..43ed6d4
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs
@@ -0,0 +1,33 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class AvaragePosition : MonoBehaviour
+ {
+ public Transform[] transforms;
+
+ private Transform rotationHelper;
+
+ public Vector3 offset;
+
+ private void Start()
+ {
+ rotationHelper = base.transform.root.GetComponentInChildren<RotationTarget>().transform;
+ }
+
+ private void LateUpdate()
+ {
+ Vector3 zero = Vector3.zero;
+ for (int i = 0; i < transforms.Length; i++)
+ {
+ zero += transforms[i].position;
+ }
+ zero /= (float)transforms.Length;
+ base.transform.position = zero + rotationHelper.TransformDirection(offset);
+ }
+ }
+
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs.meta
new file mode 100644
index 0000000..b261aa1
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/AvaragePosition.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 50fcd30d4eaec244ba38c1a668d04cd7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs
new file mode 100644
index 0000000..46dc7fd
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs
@@ -0,0 +1,20 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class CameraManager : MonoBehaviour
+ {
+ // Start is called before the first frame update
+ void Start()
+ {
+ Cursor.lockState = CursorLockMode.Locked;
+ Cursor.visible = false;
+ }
+
+ }
+
+
+} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs.meta
new file mode 100644
index 0000000..2685dde
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eb842cd2348a82a4da482f35c434de80
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraMovement.cs b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraMovement.cs
index c988991..dd21770 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraMovement.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Camera/CameraMovement.cs
@@ -1,23 +1,121 @@
+using Rigging.BodyPart;
+using Rigging.Data;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
-namespace Rigging.Camera
+namespace Rigging.Cameras
{
public class CameraMovement : MonoBehaviour
{
- // Start is called before the first frame update
- void Start()
+ public Camera camera;
+
+ public Transform positionTarget;
+
+ //public Transform headPosition;
+
+ public Transform rotationTarget;
+
+ //public Transform bobberTarget;
+
+ private StandingDataHandler standingData;
+
+ private float fallingValue;
+
+ private float fallingEffectValue;
+
+ private float minBobble = 0.02f;
+
+ public bool ADS;
+
+ //public DamageEffects effects;
+
+ //private WeaponHandler weaponHandler;
+
+ private Rigidbody hip;
+
+ //private HasControl hasControl;
+
+ //private HeadCollisionHandler headCollisionHandler;
+
+ private MovementDataHandler movementData;
+
+ private Rigidbody torso;
+
+ //private PlayerDeath death;
+
+ private Strength str;
+
+ private Vector3 cameraCurrentRelativeADSPosition = Vector3.zero;
+
+ private Vector3 movementADSVelocity = Vector3.zero;
+
+ private Vector3 ADSMovementPosition = Vector3.zero;
+
+ private void Start()
{
+ torso = base.transform.root.GetComponentInChildren<Torso>().GetComponent<Rigidbody>();
+ //headCollisionHandler = base.transform.root.GetComponentInChildren<HeadCollisionHandler>();
+ standingData = base.transform.root.GetComponentInChildren<StandingDataHandler>();
+ movementData = base.transform.root.GetComponentInChildren<MovementDataHandler>();
+ //weaponHandler = base.transform.GetComponentInParent<WeaponHandler>();
+ camera = GetComponentInChildren<Camera>();
+ hip = base.transform.root.GetComponentInChildren<Hip>().GetComponentInChildren<Rigidbody>();
+ //hasControl = base.transform.root.GetComponent<HasControl>();
+ //death = base.transform.root.GetComponent<PlayerDeath>();
+ str = base.transform.root.GetComponentInChildren<Strength>();
+ //effects = base.transform.root.GetComponent<DamageEffects>();
+ }
+ private void LateUpdate()
+ {
+ //headCollisionHandler.collisionValue = 0f;
+ if (standingData.sinceLanded > 1f)
+ {
+ fallingValue = Mathf.Clamp(standingData.sinceGrounded - 0.5f, 0f, 10f) * 0.5f;
+ }
+ if (standingData.sinceGrounded > 0.5f || standingData.sinceLanded < 0.5f)
+ {
+ fallingEffectValue = Mathf.Lerp(fallingEffectValue, fallingValue, Time.smoothDeltaTime * 15f);
+ }
+ else
+ {
+ fallingEffectValue = Mathf.Lerp(fallingEffectValue, minBobble, Time.smoothDeltaTime * 3f);
+ }
+ Vector3 position = positionTarget.position;
+ base.transform.position = position;
+ base.transform.rotation = rotationTarget.rotation;
+ SetCameraPosition();
}
- // Update is called once per frame
- void Update()
+ private void SetCameraPosition()
{
+ camera.transform.localPosition = Vector3.Lerp(camera.transform.localPosition, Vector3.zero, Time.deltaTime * 20f);
+ camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, 90f, Time.deltaTime * 20f);
+ }
+ private void FixedUpdate()
+ {
}
+
+ private void Update()
+ {
+ //if (hasControl.hasControl)
+ //{
+ // ADSMovementPosition += movementADSVelocity * Time.deltaTime;
+ //}
+ }
+
+ //private float GetPhysicsValue()
+ //{
+ // float result = fallingEffectValue * 0.3f + (1f - str.strength) + effects.damageValue;
+ // if (death.dead)
+ // {
+ // result = 1f;
+ // }
+ // return result;
+ //}
}
} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs b/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs
new file mode 100644
index 0000000..50a5a7e
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs
@@ -0,0 +1,10 @@
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class RotationTarget : MonoBehaviour
+ {
+ }
+
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs.meta
new file mode 100644
index 0000000..ae1bc80
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Camera/RotationTarget.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d6017d73a8e55c946960548b77bb264b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
index b581821..48550e5 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
@@ -52,14 +52,14 @@ namespace Rigging.Data
public T CurrentValue()
{
- return values[player.status.animation.animationState];
+ return values[Mathf.Clamp(player.status.animation.animationState, 0, values.Length - 1)];
}
public T current
{
get
{
- return values[player.status.animation.animationState];
+ return values[Mathf.Clamp(player.status.animation.animationState, 0, values.Length - 1)];
}
}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs b/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs
new file mode 100644
index 0000000..86b3265
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs
@@ -0,0 +1,22 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class FollowRotation : MonoBehaviour
+ {
+ public Transform target;
+
+ private void Start()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ base.transform.rotation = target.rotation;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs.meta
new file mode 100644
index 0000000..b3c5770
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/FollowRotation.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ec1f4e1c4a2dd4f41ad1d508b1c12670
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs b/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs
new file mode 100644
index 0000000..d64ce97
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs
@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class FollowTransform : MonoBehaviour
+ {
+ public Transform target;
+
+ public Vector3 offset;
+
+ private void Start()
+ {
+ }
+
+ private void LateUpdate()
+ {
+ base.transform.position = target.position + offset;
+ }
+ }
+
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs.meta
new file mode 100644
index 0000000..989e81d
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/FollowTransform.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 73a2f45ff0944e442b2a14ada16c195f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs
index d32d67d..f5e5ea2 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Input/InputHandler.cs
@@ -1,4 +1,4 @@
-using Rigging.Camera;
+using Rigging.Cameras;
using Rigging.Data;
using System;
using System.Collections;
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Player.cs b/ActiveRagdoll/Assets/TABG/Scripts/Player.cs
index e07da7f..6088901 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Player.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Player.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using Rigging.Data;
using Rigging.Action;
-using Rigging.Camera;
+using Rigging.Cameras;
using System;
using Rigging.BodyPart;
using Rigging.Inputs;
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs b/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs
new file mode 100644
index 0000000..3e1ee14
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs
@@ -0,0 +1,126 @@
+using UnityEngine;
+
+namespace Rigging
+{
+
+ public class RotateByMouseInput : MonoBehaviour
+ {
+ public enum XSpace
+ {
+ self,
+ world
+ }
+
+ public enum YSpace
+ {
+ self,
+ world
+ }
+
+ public bool useX;
+
+ public XSpace xSpace;
+
+ public Vector3 xVector;
+
+ public bool useY;
+
+ public YSpace ySpace;
+
+ public Vector3 yVector;
+
+ [Header("Control")]
+ public bool needControl;
+
+ public bool needAlive;
+
+ public bool freezeUnusedAngles;
+
+ //private HasControl hasControl;
+
+ //private PlayerDeath death;
+
+ private float m = 1f;
+
+ private void Start()
+ {
+ //if (needControl)
+ //{
+ // hasControl = base.transform.root.GetComponent<HasControl>();
+ //}
+ //if (needAlive)
+ //{
+ // death = base.transform.root.GetComponent<PlayerDeath>();
+ //}
+ }
+
+ private void LateUpdate()
+ {
+ //if (needControl && !hasControl.hasControl)
+ //{
+ // return;
+ //}
+ //if (needAlive)
+ //{
+ // m = Mathf.Clamp(death.muscleFunction * 2f, 0f, 1f);
+ // if (death.dead)
+ // {
+ // return;
+ // }
+ //}
+ if (useX)
+ {
+ Vector3 vector = xVector;
+ if (xSpace == XSpace.self)
+ {
+ vector = base.transform.TransformDirection(vector);
+ }
+ base.transform.Rotate(vector * Input.GetAxis("Mouse X") * m * 0.8f, Space.World);
+ }
+ if (useY)
+ {
+ Vector3 vector2 = yVector;
+ if (ySpace == YSpace.self)
+ {
+ vector2 = base.transform.TransformDirection(vector2);
+ }
+ base.transform.Rotate(vector2 * Input.GetAxis("Mouse Y") * m * 0.8f, Space.World);
+ }
+ if (!freezeUnusedAngles)
+ {
+ return;
+ }
+ if (useY)
+ {
+ if (yVector.x == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(0f, base.transform.localEulerAngles.y, base.transform.localEulerAngles.z);
+ }
+ if (yVector.y == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(base.transform.localEulerAngles.x, 0f, base.transform.localEulerAngles.z);
+ }
+ if (yVector.z == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(base.transform.localEulerAngles.x, base.transform.localEulerAngles.y, 0f);
+ }
+ }
+ if (useX)
+ {
+ if (xVector.x == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(0f, base.transform.localEulerAngles.y, base.transform.localEulerAngles.z);
+ }
+ if (xVector.y == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(base.transform.localEulerAngles.x, 0f, base.transform.localEulerAngles.z);
+ }
+ if (xVector.z == 0f)
+ {
+ base.transform.localRotation = Quaternion.Euler(base.transform.localEulerAngles.x, base.transform.localEulerAngles.y, 0f);
+ }
+ }
+ }
+ }
+
+}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs.meta b/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs.meta
new file mode 100644
index 0000000..8321f09
--- /dev/null
+++ b/ActiveRagdoll/Assets/TABG/Scripts/RotateByMouseInput.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a8f75acb6587ee74a9cfb051869e7a39
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: