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 | |
| parent | f53954271f078db7b593057538846c344b341e33 (diff) | |
完成了罗师傅的移动系统
Diffstat (limited to 'Assets/Scripts')
| -rw-r--r-- | Assets/Scripts/PlayerRotationController.cs | 23 | ||||
| -rw-r--r-- | Assets/Scripts/Tag.meta | 8 | ||||
| -rw-r--r-- | Assets/Scripts/Tag/TaggedItem.cs | 29 | ||||
| -rw-r--r-- | Assets/Scripts/Tag/TaggedItem.cs.meta | 2 |
4 files changed, 61 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); + } } diff --git a/Assets/Scripts/Tag.meta b/Assets/Scripts/Tag.meta new file mode 100644 index 0000000..6fcec23 --- /dev/null +++ b/Assets/Scripts/Tag.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b908413dc2c80db0ab49168853421d38 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Tag/TaggedItem.cs b/Assets/Scripts/Tag/TaggedItem.cs new file mode 100644 index 0000000..12e05f5 --- /dev/null +++ b/Assets/Scripts/Tag/TaggedItem.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Tag +{ + [CreateAssetMenu(fileName = "TaggedItem", menuName = "Scriptable Objects/TaggedItem")] + public class TaggedItem : ScriptableObject + { + public ItemType itemType; + public Sprite image; + public List<string> tags; + } + + [Serializable] + public enum ItemType + { + [InspectorName("眼睛")] + Eye, + [InspectorName("鼻子")] + Norse, + [InspectorName("眉毛")] + Elbow, + [InspectorName("嘴巴")] + Mouse, + [InspectorName("配饰")] + Accessories + } +} diff --git a/Assets/Scripts/Tag/TaggedItem.cs.meta b/Assets/Scripts/Tag/TaggedItem.cs.meta new file mode 100644 index 0000000..8d62664 --- /dev/null +++ b/Assets/Scripts/Tag/TaggedItem.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: edcb65f129a9b03b0af0009c24d499bd
\ No newline at end of file |
