diff options
| author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 | 
|---|---|---|
| committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 | 
| commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
| tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/LegRotator.cs | |
+ init
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)); +			} +		} +	} +}  | 
