diff options
Diffstat (limited to 'Assets')
| -rw-r--r-- | Assets/MultiplayInput.inputactions | 154 | ||||
| -rw-r--r-- | Assets/Prefabs/Player.prefab | 58 | ||||
| -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 | ||||
| -rw-r--r-- | Assets/TaggedItems.meta | 8 |
7 files changed, 279 insertions, 3 deletions
diff --git a/Assets/MultiplayInput.inputactions b/Assets/MultiplayInput.inputactions index b3e169c..3c08fce 100644 --- a/Assets/MultiplayInput.inputactions +++ b/Assets/MultiplayInput.inputactions @@ -38,6 +38,116 @@ "isPartOfComposite": false }, { + "name": "2D Vector", + "id": "e62fc7fa-06f3-45fe-a37d-ba8972c8ef98", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "a9759bca-4731-4b1f-866c-2c0df76e881c", + "path": "<Keyboard>/w", + "interactions": "", + "processors": "", + "groups": ";PlayerA", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "318fec5a-0927-49c0-bf18-a37951f4ff59", + "path": "<Keyboard>/s", + "interactions": "", + "processors": "", + "groups": ";PlayerA", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "fd270657-2d49-4d83-a669-aa297a4daf0d", + "path": "<Keyboard>/a", + "interactions": "", + "processors": "", + "groups": ";PlayerA", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "4b75a3bb-bd04-42d2-9808-b24896463f86", + "path": "<Keyboard>/d", + "interactions": "", + "processors": "", + "groups": ";PlayerA", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "2D Vector", + "id": "170dc890-7676-4781-9eba-9781c9d57213", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "f1fa6215-cf75-4617-80a7-9a2910b04207", + "path": "<Keyboard>/upArrow", + "interactions": "", + "processors": "", + "groups": ";PlayerB", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "9d120c86-fbe8-4cf3-bbc5-3cb4e74ac6f4", + "path": "<Keyboard>/downArrow", + "interactions": "", + "processors": "", + "groups": ";PlayerB", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "b4d82347-987b-41e9-a4b5-ee4f483aab6f", + "path": "<Keyboard>/leftArrow", + "interactions": "", + "processors": "", + "groups": ";PlayerB", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "bcc1dcdb-53b6-48a5-a69d-52284a6f224f", + "path": "<Keyboard>/rightArrow", + "interactions": "", + "processors": "", + "groups": ";PlayerB", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { "name": "", "id": "ba722a4c-12ce-40df-bb52-43672eec34fc", "path": "<Gamepad>/buttonSouth", @@ -47,6 +157,28 @@ "action": "Grabbing", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "c7a7e159-3dd0-41ca-bda7-8dbece6db3ef", + "path": "<Keyboard>/g", + "interactions": "", + "processors": "", + "groups": ";PlayerA", + "action": "Grabbing", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "5c1c8d15-ca01-4cef-8337-188691347106", + "path": "<Keyboard>/rightCtrl", + "interactions": "", + "processors": "", + "groups": ";PlayerB", + "action": "Grabbing", + "isComposite": false, + "isPartOfComposite": false } ] } @@ -62,6 +194,28 @@ "isOR": false } ] + }, + { + "name": "PlayerA", + "bindingGroup": "PlayerA", + "devices": [ + { + "devicePath": "<Keyboard>", + "isOptional": false, + "isOR": false + } + ] + }, + { + "name": "PlayerB", + "bindingGroup": "PlayerB", + "devices": [ + { + "devicePath": "<Keyboard>", + "isOptional": false, + "isOR": false + } + ] } ] }
\ No newline at end of file diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index e70f94a..2e8ced1 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -141,6 +141,7 @@ Transform: m_Children: - {fileID: 3858086185141390273} - {fileID: 8065121896564615395} + - {fileID: 4408286991926610371} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!54 &6800731054372189146 @@ -368,6 +369,7 @@ GameObject: m_Component: - component: {fileID: 3858086185141390273} - component: {fileID: 8017654697833592608} + - component: {fileID: 1683818354991653245} m_Layer: 0 m_Name: PlayerRotation m_TagString: Untagged @@ -383,7 +385,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4361574340126228034} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -403,7 +405,59 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7ef2d969201f5284b968982b605fb3ff, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::PlayerRotationController - playerControl: {fileID: 5427005771150001327} + lookAt: {fileID: 4408286991926610371} + control: {fileID: 3267697200445213522} +--- !u!1183024399 &1683818354991653245 +LookAtConstraint: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4361574340126228034} + m_Enabled: 1 + serializedVersion: 2 + m_Weight: 1 + m_RotationAtRest: {x: 0, y: 0, z: 0} + m_RotationOffset: {x: 0, y: 0, z: 0} + m_Roll: 0 + m_WorldUpObject: {fileID: 0} + m_UseUpObject: 0 + m_Active: 1 + m_IsLocked: 1 + m_Sources: + - sourceTransform: {fileID: 4408286991926610371} + weight: 1 +--- !u!1 &4683232950500733684 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4408286991926610371} + m_Layer: 0 + m_Name: LookAt + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4408286991926610371 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4683232950500733684} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2684917141693768409} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &7321994139321691109 GameObject: m_ObjectHideFlags: 0 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 diff --git a/Assets/TaggedItems.meta b/Assets/TaggedItems.meta new file mode 100644 index 0000000..f4d8ea3 --- /dev/null +++ b/Assets/TaggedItems.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f69ac15ed28c3f91bffcec436847a22 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: |
