From 805aeb2d821f0f9acd2133c9aaf87851d8ee58d4 Mon Sep 17 00:00:00 2001 From: OverflowNarhoym Date: Fri, 25 Feb 2022 19:05:28 +0100 Subject: [PATCH] Updated platform scripts --- Assets/Scenes/OverDevScene.unity | 93 +++++++++++++++++-- .../Scripts/Platforms/CollapsingPlatform.cs | 5 +- Assets/Scripts/Platforms/MovingPlatform.cs | 4 +- 3 files changed, 87 insertions(+), 15 deletions(-) diff --git a/Assets/Scenes/OverDevScene.unity b/Assets/Scenes/OverDevScene.unity index 810eef3..c6e4cff 100644 --- a/Assets/Scenes/OverDevScene.unity +++ b/Assets/Scenes/OverDevScene.unity @@ -123,6 +123,79 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &53543450 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalPosition.x + value: 8.327312 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalPosition.y + value: -2.1712146 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_BodyType + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_Constraints + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_Interpolate + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_GravityScale + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3453266731971349118, guid: 821831f062ee52848b6bda27fba0b001, type: 3} + propertyPath: m_Name + value: Moving_Platform_Medium + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 821831f062ee52848b6bda27fba0b001, type: 3} --- !u!1 &387708699 GameObject: m_ObjectHideFlags: 0 @@ -209,7 +282,7 @@ Transform: m_Children: - {fileID: 1287783379} m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!61 &387708702 BoxCollider2D: @@ -254,10 +327,10 @@ Rigidbody2D: m_AngularDrag: 0.05 m_GravityScale: 1 m_Material: {fileID: 0} - m_Interpolate: 0 + m_Interpolate: 1 m_SleepingMode: 1 - m_CollisionDetection: 0 - m_Constraints: 0 + m_CollisionDetection: 1 + m_Constraints: 4 --- !u!114 &387708704 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2481,7 +2554,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} propertyPath: m_RootOrder - value: 5 + value: 6 objectReference: {fileID: 0} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} propertyPath: m_LocalPosition.x @@ -2714,7 +2787,7 @@ Transform: m_Children: - {fileID: 434782289} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1692941248 PrefabInstance: @@ -2729,7 +2802,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} propertyPath: m_RootOrder - value: 7 + value: 8 objectReference: {fileID: 0} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} propertyPath: m_LocalPosition.x @@ -2843,7 +2916,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3} propertyPath: m_RootOrder - value: 6 + value: 7 objectReference: {fileID: 0} - target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3} propertyPath: m_LocalPosition.x @@ -2896,7 +2969,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3} propertyPath: m_RootOrder - value: 2 + value: 3 objectReference: {fileID: 0} - target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3} propertyPath: m_LocalPosition.x @@ -2969,7 +3042,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3} propertyPath: m_RootOrder - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Scripts/Platforms/CollapsingPlatform.cs b/Assets/Scripts/Platforms/CollapsingPlatform.cs index 0b4aa6a..7a1ae49 100644 --- a/Assets/Scripts/Platforms/CollapsingPlatform.cs +++ b/Assets/Scripts/Platforms/CollapsingPlatform.cs @@ -21,7 +21,6 @@ namespace Platforms private void Update() { if (!_collidingTriggerCheck.IsCollided || _onCollision) return; - Debug.Log("On collision"); _onCollision = true; StartCoroutine(Collapse()); } @@ -34,7 +33,7 @@ namespace Platforms private IEnumerator Collapse() { - //changer sprite en rouge + GetComponent().color = Color.red; yield return new WaitForSeconds(TimeBeforeCollapse); ChangeState(false); StartCoroutine(Reset()); @@ -45,7 +44,7 @@ namespace Platforms { yield return new WaitForSeconds(TimeBeforeReset); _onCollision = false; - //change sprite en normal + GetComponent().color = Color.white; ChangeState(true); } } diff --git a/Assets/Scripts/Platforms/MovingPlatform.cs b/Assets/Scripts/Platforms/MovingPlatform.cs index a8fc7d6..ea83d3a 100644 --- a/Assets/Scripts/Platforms/MovingPlatform.cs +++ b/Assets/Scripts/Platforms/MovingPlatform.cs @@ -60,13 +60,13 @@ namespace Platforms switch (_goingToFuturePos) { case true: - transform.position += new Vector3(0.05f, 0, 0); + _platformRigidbody.AddForce(Vector2.left * 100.0f * Time.deltaTime, ForceMode2D.Impulse); if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset && Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset) _goingToFuturePos = false; break; case false: - transform.position += new Vector3(-0.05f, 0, 0); + _platformRigidbody.AddForce(Vector2.left * -100.0f * Time.deltaTime, ForceMode2D.Impulse); if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset && Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset) _goingToFuturePos = true;