diff options
Diffstat (limited to 'GameCode/LegRotator.cs')
-rw-r--r-- | GameCode/LegRotator.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/GameCode/LegRotator.cs b/GameCode/LegRotator.cs new file mode 100644 index 0000000..35e95b7 --- /dev/null +++ b/GameCode/LegRotator.cs @@ -0,0 +1,26 @@ +using UnityEngine; + +public class LegRotator : MonoBehaviour +{ + private PlayerVelocity rig; + + private void Start() + { + rig = GetComponentInParent<PlayerVelocity>(); + } + + private void Update() + { + if ((bool)rig) + { + if (rig.velocity.x < 0f) + { + base.transform.localEulerAngles = Vector3.Lerp(base.transform.localEulerAngles, new Vector3(0f, 0f, 0f), TimeHandler.deltaTime * 15f * Mathf.Clamp(Mathf.Abs(rig.velocity.x), 0f, 1f)); + } + else + { + base.transform.localEulerAngles = Vector3.Lerp(base.transform.localEulerAngles, new Vector3(0f, 180f, 0f), TimeHandler.deltaTime * 15f * Mathf.Clamp(Mathf.Abs(rig.velocity.x), 0f, 1f)); + } + } + } +} |