diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-31 11:10:04 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-31 11:10:04 +0800 |
| commit | 343a1aa731a85a8a866d0466d29931e5a9c8dfb0 (patch) | |
| tree | db25f16a9a4ddb0cf7c973d748023b9f680b8501 /Assets/Scripts/PlayerRotationController.cs | |
| parent | f53954271f078db7b593057538846c344b341e33 (diff) | |
完成了罗师傅的移动系统
Diffstat (limited to 'Assets/Scripts/PlayerRotationController.cs')
| -rw-r--r-- | Assets/Scripts/PlayerRotationController.cs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Assets/Scripts/PlayerRotationController.cs b/Assets/Scripts/PlayerRotationController.cs index d43ef36..e339116 100644 --- a/Assets/Scripts/PlayerRotationController.cs +++ b/Assets/Scripts/PlayerRotationController.cs @@ -3,5 +3,26 @@ using UnityEngine; public class PlayerRotationController : MonoBehaviour { - + [Range(0, 1)] public float lerpSpeed = 0.25f; + public Transform lookAt; + public PlayerControl control; + + private readonly float _len = 5f; + private Vector3 _target; + + private void Update() + { + var dir = new Vector3(control.movementHorizontal, 0, control.movementVertical).normalized; + if (dir != Vector3.zero) + { + _target = dir * _len; + // lookAt.localPosition = _target; + } + } + + private void FixedUpdate() + { + var pos = lookAt.localPosition; + lookAt.localPosition = Vector3.Lerp(pos, _target, lerpSpeed); + } } |
