From be53fd73d5bcb6917ffabd0788c7d0362df29587 Mon Sep 17 00:00:00 2001 From: Yogi <1273750265@qq.com> Date: Thu, 9 Jan 2025 21:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=8B=E8=BD=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/Main.unity | 130 ++++++++++++++++-- Assets/Scripts/RotateAroundTargetAnim.cs | 31 +++++ Assets/Scripts/RotateAroundTargetAnim.cs.meta | 2 + 3 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 Assets/Scripts/RotateAroundTargetAnim.cs create mode 100644 Assets/Scripts/RotateAroundTargetAnim.cs.meta diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index b0a7391..2d3b752 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -245,6 +245,31 @@ Transform: m_Children: [] m_Father: {fileID: 604712594} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &223334191 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 5218155922998809704, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + m_PrefabInstance: {fileID: 6664335491598370550} + m_PrefabAsset: {fileID: 0} +--- !u!4 &223334192 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + m_PrefabInstance: {fileID: 6664335491598370550} + m_PrefabAsset: {fileID: 0} +--- !u!114 &223334193 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 223334191} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2456e189d175ec14f981ec5dc8f21b33, type: 3} + m_Name: + m_EditorClassIdentifier: + target: {fileID: 223334192} + rotateSpeed: -30 + FreeTime: 30 --- !u!1 &251978103 GameObject: m_ObjectHideFlags: 0 @@ -1351,6 +1376,53 @@ GameObject: m_CorrespondingSourceObject: {fileID: 5506468342675174862, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} m_PrefabInstance: {fileID: 6664335491598370550} m_PrefabAsset: {fileID: 0} +--- !u!1 &1241170118 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1241170119} + - component: {fileID: 1241170120} + m_Layer: 0 + m_Name: RotateCameraCenter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &1241170119 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1241170118} + serializedVersion: 2 + m_LocalRotation: {x: 0.14195606, y: 0.14415787, z: -0.020900985, w: 0.9790966} + m_LocalPosition: {x: -2.7635517, y: 2.840037, z: -9.181348} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1241170120 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1241170118} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2456e189d175ec14f981ec5dc8f21b33, type: 3} + m_Name: + m_EditorClassIdentifier: + target: {fileID: 668196392} + rotateSpeed: 0.1 + FreeTime: 1 --- !u!1 &1288110412 stripped GameObject: m_CorrespondingSourceObject: {fileID: 2881457540606939832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} @@ -1792,27 +1864,27 @@ PrefabInstance: m_Modifications: - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalPosition.x - value: -0.03 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalPosition.y - value: -0.6 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalPosition.z - value: -1.08 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalRotation.w - value: -0.05573427 + value: 1 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalRotation.x - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalRotation.y - value: -0.99844563 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalRotation.z @@ -1824,25 +1896,65 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalEulerAnglesHint.y - value: -186.39 + value: 0 objectReference: {fileID: 0} - target: {fileID: 251226097386157602, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalPosition.x + value: -0.03 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalPosition.y + value: -0.6 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalPosition.z + value: -1.08 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalRotation.w + value: -0.05573427 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalRotation.y + value: -0.99844563 + objectReference: {fileID: 0} + - target: {fileID: 4332512220139617832, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4830004066221561861, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 5218155922998809704, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} propertyPath: m_Name - value: "\u6839\u8282\u70B9(\u63A7\u5236\u5168\u8F66\u65CB\u8F6C)" + value: "\u6839\u8282\u70B9(\u4E0D\u8981\u4FEE\u6539\u4F4D\u7F6E)" + objectReference: {fileID: 0} + - target: {fileID: 7574252367231446458, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + propertyPath: m_Name + value: "\u8F66\u8F86Body(\u53EF\u4EE5\u4FEE\u6539\u5750\u6807\u4E0E\u65CB\u8F6C)" objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 5218155922998809704, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} + insertIndex: -1 + addedObject: {fileID: 223334193} m_SourcePrefab: {fileID: 100100000, guid: 741d148cf7fe4db4aa6687915c30f4ca, type: 3} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: + - {fileID: 1241170119} - {fileID: 961739753} - {fileID: 668196392} - {fileID: 1160234427} diff --git a/Assets/Scripts/RotateAroundTargetAnim.cs b/Assets/Scripts/RotateAroundTargetAnim.cs new file mode 100644 index 0000000..c144ba5 --- /dev/null +++ b/Assets/Scripts/RotateAroundTargetAnim.cs @@ -0,0 +1,31 @@ +using System; +using UnityEngine; + +public class RotateAroundTargetAnim : MonoBehaviour +{ + public Transform target; + public float rotateSpeed = .1f; + + private float triggerTimer; + public float FreeTime = 1; + + private void FixedUpdate() + { + if (triggerTimer >= FreeTime) + { + this.transform.RotateAround(target.position, target.up, Time.fixedDeltaTime * rotateSpeed); + } + } + + private void Update() + { + if (Input.anyKey) + { + triggerTimer = 0; + } + else + { + triggerTimer += Time.deltaTime; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/RotateAroundTargetAnim.cs.meta b/Assets/Scripts/RotateAroundTargetAnim.cs.meta new file mode 100644 index 0000000..696e0ac --- /dev/null +++ b/Assets/Scripts/RotateAroundTargetAnim.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 2456e189d175ec14f981ec5dc8f21b33 \ No newline at end of file