using ECM2; using Obvious.Soap; using UnityEngine; public class PlayerSharedVariables : MonoBehaviour { public BoolVariable IsPlayerRunning; public FloatVariable CurrentMoveSpeed; public FloatVariable RotationSpeed; public BoolVariable IsGrounded; public Vector3Variable StartPosition; private CharacterMovement _CharMovement; public float TargetMultiplier = 1f; public float DecayRot = 0.01f; private Quaternion lastRotation; private void Awake() { _CharMovement = GetComponent(); } private void Start() { base.transform.position = StartPosition.Value; } private void Update() { Quaternion rotation = base.transform.rotation; float num = Quaternion.Angle(rotation, lastRotation); float num2 = ((Vector3.Cross(lastRotation * Vector3.forward, rotation * Vector3.forward).y > 0f) ? 1f : (-1f)); bool flag = num > 0f; if (!flag) { RotationSpeed.Value = Mathf.Lerp(RotationSpeed.Value, 0f, DecayRot * Time.deltaTime); } lastRotation = rotation; IsGrounded.Value = _CharMovement.isGrounded; Vector3 velocity = _CharMovement.velocity; velocity.y = 0f; CurrentMoveSpeed.Value = velocity.magnitude; float num3 = ((CurrentMoveSpeed.Value < 1f) ? (TargetMultiplier * 5f) : TargetMultiplier); RotationSpeed.Value += (flag ? 1f : 0f) * num2 * Time.deltaTime * (IsPlayerRunning.Value ? (num3 * 0.075f) : num3); } }