From 20c11f705c27333d9fd83192d260670541e18546 Mon Sep 17 00:00:00 2001 From: HeosFx <82534081+HeosFx@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:17:22 +0200 Subject: [PATCH 1/2] Add reset pose disc --- Assets/Scenes/MainMenu.unity | 17 ++++++++++++++++- Assets/scripts/ResetDiscPose.cs | 26 ++++++++++++++++++++++++++ Assets/scripts/ResetDiscPose.cs.meta | 11 +++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Assets/scripts/ResetDiscPose.cs create mode 100644 Assets/scripts/ResetDiscPose.cs.meta diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index df1ba36..6f6ff0d 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -137,6 +137,7 @@ GameObject: - component: {fileID: 81522045} - component: {fileID: 81522043} - component: {fileID: 81522046} + - component: {fileID: 81522047} m_Layer: 0 m_Name: snap_disque m_TagString: disque_song1 @@ -194,7 +195,7 @@ Transform: m_GameObject: {fileID: 81522039} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.219, y: 0.388, z: 0.7786} + m_LocalPosition: {x: -0.226, y: 0.387, z: 0.7786} m_LocalScale: {x: 1.2475, y: 1.2475, z: 1.2475} m_ConstrainProportionsScale: 0 m_Children: @@ -339,6 +340,20 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &81522047 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 81522039} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 92bb0a8c26925204c92f284e9c43f3b9, type: 3} + m_Name: + m_EditorClassIdentifier: + disc: {fileID: 81522039} + resetY: -0.03 --- !u!1 &214932422 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/scripts/ResetDiscPose.cs b/Assets/scripts/ResetDiscPose.cs new file mode 100644 index 0000000..f2f546d --- /dev/null +++ b/Assets/scripts/ResetDiscPose.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ResetDiscPose : MonoBehaviour +{ + public GameObject disc; + private Transform initTransform; + public float resetY = -10.0f; + + // Start is called before the first frame update + void Start() + { + initTransform = disc.transform; + } + + // Update is called once per frame + void Update() + { + if (disc.transform.position.y < resetY) + { + disc.transform.position = initTransform.position; + disc.transform.rotation = initTransform.rotation; + } + } +} diff --git a/Assets/scripts/ResetDiscPose.cs.meta b/Assets/scripts/ResetDiscPose.cs.meta new file mode 100644 index 0000000..8388d60 --- /dev/null +++ b/Assets/scripts/ResetDiscPose.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 92bb0a8c26925204c92f284e9c43f3b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 1d7d3b4310f1a331d1794346c69671c8e14435af Mon Sep 17 00:00:00 2001 From: HeosFx <82534081+HeosFx@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:38:07 +0200 Subject: [PATCH 2/2] Fix reset pose disc --- Assets/scripts/ResetDiscPose.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Assets/scripts/ResetDiscPose.cs b/Assets/scripts/ResetDiscPose.cs index f2f546d..1069354 100644 --- a/Assets/scripts/ResetDiscPose.cs +++ b/Assets/scripts/ResetDiscPose.cs @@ -5,22 +5,27 @@ public class ResetDiscPose : MonoBehaviour { public GameObject disc; - private Transform initTransform; + private float initX; + private float initY; + private float initZ; public float resetY = -10.0f; // Start is called before the first frame update void Start() { - initTransform = disc.transform; + initX = disc.transform.position.x; + initY = disc.transform.position.y; + initZ = disc.transform.position.z; } // Update is called once per frame void Update() { + if (disc.transform.position.y < resetY) { - disc.transform.position = initTransform.position; - disc.transform.rotation = initTransform.rotation; + disc.transform.position = new Vector3(initX, initY, initZ); + disc.transform.rotation = Quaternion.identity; } } }