diff --git a/xiaofang/Assets/Joystick Pack.meta b/xiaofang/Assets/Joystick Pack.meta deleted file mode 100644 index 06f0aa63..00000000 --- a/xiaofang/Assets/Joystick Pack.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8c7bbad3d8914a84e9cf38d29cf524b4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/xiaofang/Assets/Joystick Pack/Examples.meta b/xiaofang/Assets/Joystick Pack/Examples.meta deleted file mode 100644 index 70983f46..00000000 --- a/xiaofang/Assets/Joystick Pack/Examples.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: af5c8bb89e66c5a468f47dc562533b18 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/xiaofang/Assets/Joystick Pack/Scripts.meta b/xiaofang/Assets/Joystick Pack/Scripts.meta deleted file mode 100644 index 97ccf418..00000000 --- a/xiaofang/Assets/Joystick Pack/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d5858802aa57a894dbf5be38bfa99639 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/xiaofang/Assets/Joystick Pack/Scripts/Base.meta b/xiaofang/Assets/Joystick Pack/Scripts/Base.meta deleted file mode 100644 index 742b69dd..00000000 --- a/xiaofang/Assets/Joystick Pack/Scripts/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a660bf40fa9216b4081951ff42ce172e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/xiaofang/Assets/Joystick Pack/Scripts/Joysticks.meta b/xiaofang/Assets/Joystick Pack/Scripts/Joysticks.meta deleted file mode 100644 index 673c7453..00000000 --- a/xiaofang/Assets/Joystick Pack/Scripts/Joysticks.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4f75cb42737a94c4ea8303e8b2883fd8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/xiaofang/Assets/Scenes/Tmap.unity b/xiaofang/Assets/Scenes/Tmap.unity index bc9abc99..e18dc968 100644 --- a/xiaofang/Assets/Scenes/Tmap.unity +++ b/xiaofang/Assets/Scenes/Tmap.unity @@ -469,6 +469,119 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 17 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &172478309 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1039624185} + m_Modifications: + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_SizeDelta.x + value: 256 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_SizeDelta.y + value: 256 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchoredPosition.x + value: 256 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_AnchoredPosition.y + value: 256 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2929252283123773939, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + propertyPath: m_Name + value: Fixed Joystick + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} +--- !u!224 &172478310 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 2929252283123773938, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + m_PrefabInstance: {fileID: 172478309} + m_PrefabAsset: {fileID: 0} +--- !u!114 &172478311 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 2929252283123773951, guid: aaa2c939c0359ac4dbce3f49e8b90252, type: 3} + m_PrefabInstance: {fileID: 172478309} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 45977bbae16431c46a013576a1aea384, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &220116451 PrefabInstance: m_ObjectHideFlags: 0 @@ -2757,6 +2870,7 @@ RectTransform: - {fileID: 1402647586} - {fileID: 1783836472} - {fileID: 303702331} + - {fileID: 172478310} m_Father: {fileID: 0} m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -5704,6 +5818,20 @@ MonoBehaviour: m_EditorClassIdentifier: Mp: 0 Def: 0 +--- !u!114 &543450652475625314 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1511130762} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c377cd4742c7966498dda3a5e984db05, type: 3} + m_Name: + m_EditorClassIdentifier: + joystick: {fileID: 172478311} + speed: 5 --- !u!1 &1242008297200351719 stripped GameObject: m_CorrespondingSourceObject: {fileID: 5795828957522809712, guid: 2c4a835a9676e1a478c77d64f472c3ec, type: 3} diff --git a/xiaofang/Assets/Script/Character/CharacterControl.cs b/xiaofang/Assets/Script/Character/CharacterControl.cs index 2400a87a..808ef2a0 100644 --- a/xiaofang/Assets/Script/Character/CharacterControl.cs +++ b/xiaofang/Assets/Script/Character/CharacterControl.cs @@ -29,6 +29,9 @@ public class CharacterControl : MonoBehaviour //垂直和水平输入值计算出一个方向向量 Vector3 dir; + private PlayerMovement_Jpystick PlayerMovement_Jpystick; + + //判断是否在移动 private bool IsMoving = false; @@ -63,8 +66,8 @@ public class CharacterControl : MonoBehaviour // Start is called before the first frame update void Start() { - - + + PlayerMovement_Jpystick = GetComponent(); } // Update is called once per frame @@ -113,6 +116,8 @@ public class CharacterControl : MonoBehaviour vertical = Input.GetAxis("Vertical"); horizontal = Input.GetAxis("Horizontal"); + vertical = PlayerMovement_Jpystick.joystick.Vertical; + horizontal = PlayerMovement_Jpystick.joystick.Horizontal; // 使用摄像头的方向来计算角色的移动方向 Vector3 forward = mainCamera.transform.forward; // 摄像头前方 diff --git a/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs b/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs new file mode 100644 index 00000000..27b98862 --- /dev/null +++ b/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerMovement_Jpystick : MonoBehaviour +{ + public Joystick joystick; // 将Joystick拖入此处 + public float speed = 5f; + + void Update() + { + float horizontal = joystick.Horizontal; + float vertical = joystick.Vertical; + + Vector3 direction = new Vector3(horizontal, 0, vertical); + transform.Translate(direction * speed * Time.deltaTime, Space.World); + } +} diff --git a/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs.meta b/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs.meta new file mode 100644 index 00000000..479acf0a --- /dev/null +++ b/xiaofang/Assets/Script/Character/PlayerMovement_Jpystick.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c377cd4742c7966498dda3a5e984db05 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: