From 762bbf6486cc88f0326ea9fc77c36b7dd6087852 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Wed, 10 Mar 2021 17:41:09 +0000 Subject: [PATCH 1/2] wip --- .../Assets/Prefabs/Traps/FallawayFloor.prefab | 31 ++++++++++++++++++- game/Assets/Scenes/Main.unity | 20 ++++++------ game/Assets/Scripts/Traps/FallawayFloor.cs | 23 ++++++++++++-- 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/game/Assets/Prefabs/Traps/FallawayFloor.prefab b/game/Assets/Prefabs/Traps/FallawayFloor.prefab index 7a980f1..ad98513 100644 --- a/game/Assets/Prefabs/Traps/FallawayFloor.prefab +++ b/game/Assets/Prefabs/Traps/FallawayFloor.prefab @@ -26,6 +26,7 @@ GameObject: - component: {fileID: 980120856895548940} - component: {fileID: 980120856895548939} - component: {fileID: 980120856895548943} + - component: {fileID: 3536778402394572832} m_Layer: 0 m_Name: FallawayFloor m_TagString: Untagged @@ -100,8 +101,36 @@ Rigidbody: m_UseGravity: 0 m_IsKinematic: 0 m_Interpolate: 0 - m_Constraints: 0 + m_Constraints: 122 m_CollisionDetection: 0 +--- !u!114 &3536778402394572832 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8773676356524340268} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a5de09a27d949d4db67034f55c57e6b, type: 3} + m_Name: + m_EditorClassIdentifier: + _event: {fileID: 11400000, guid: 6e31084a96bb93a44a85563a6208d0da, type: 2} + _response: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 980120856895548939} + m_TargetAssemblyTypeName: FallawayFloor, Assembly-CSharp + m_MethodName: Reset + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!1001 &5711263752094586620 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index 4a4c6af..bd46af3 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -2538,11 +2538,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: -0.017264403 + value: -0.017264389 objectReference: {fileID: 0} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: 0.009297725 + value: 0.009297717 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalPosition.x @@ -2558,19 +2558,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.9680315 + value: 0.968031 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.24655113 + value: 0.24655096 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.044697873 + value: 0.044709474 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.011384248 + value: -0.011387202 objectReference: {fileID: 0} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_Name @@ -2702,19 +2702,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.9996367 + value: 0.9996364 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.0047710985 + value: 0.0047711134 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.023356276 + value: 0.023366831 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.012578499 + value: -0.0125841815 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} diff --git a/game/Assets/Scripts/Traps/FallawayFloor.cs b/game/Assets/Scripts/Traps/FallawayFloor.cs index bef9840..b7099a7 100644 --- a/game/Assets/Scripts/Traps/FallawayFloor.cs +++ b/game/Assets/Scripts/Traps/FallawayFloor.cs @@ -1,8 +1,10 @@ using System; using System.Collections; using System.Collections.Generic; +using UnityEditor; using UnityEngine; +[RequireComponent(typeof(Rigidbody))] public class FallawayFloor : MonoBehaviour { // Speed at which the object moves towards the ground. @@ -12,10 +14,11 @@ public class FallawayFloor : MonoBehaviour // Time taken for object to be destroyed. public float destroyObjectTime; public Material dissolve; - + [SerializeField] private Renderer _renderer; Rigidbody rb; + private Vector3 _initialPosition; private void Start() { @@ -29,7 +32,7 @@ public class FallawayFloor : MonoBehaviour { // Start the Destroy floor coroutine and switch to the dissolve material. StartCoroutine(DestroyFloor()); - _renderer.material = dissolve; + // _renderer.material = dissolve; } } @@ -37,9 +40,23 @@ public class FallawayFloor : MonoBehaviour { // Take fallAwayTime, speed, and destroyObjectTime from editor and apply yield return new WaitForSeconds(fallAwayTime); + rb.velocity = Vector3.down * speed; + yield return new WaitForSeconds(destroyObjectTime); - Destroy(gameObject); + // Destroy(gameObject); + } + + public void Reset() + { + transform.position = _initialPosition; } } + +#if UNITY_EDITOR +public class FallawayFloorEditor : Editor +{ + +} +#endif From d5de30107f7374e2819d0a6c2996286df77bd31f Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Wed, 10 Mar 2021 18:26:33 +0000 Subject: [PATCH 2/2] reset falling floor trap position on player respawn --- .../Assets/Prefabs/Traps/FallawayFloor.prefab | 2 +- game/Assets/Scenes/Main.unity | 22 ++++++------- game/Assets/Scripts/Traps/FallawayFloor.cs | 33 +++++++------------ 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/game/Assets/Prefabs/Traps/FallawayFloor.prefab b/game/Assets/Prefabs/Traps/FallawayFloor.prefab index ad98513..00d2b5e 100644 --- a/game/Assets/Prefabs/Traps/FallawayFloor.prefab +++ b/game/Assets/Prefabs/Traps/FallawayFloor.prefab @@ -82,7 +82,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3} m_Name: m_EditorClassIdentifier: - speed: 3 + speed: 10 fallAwayTime: 1 destroyObjectTime: 0 dissolve: {fileID: 2100000, guid: 98767dd77414bad44b23ef5332c1d8f1, type: 2} diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index bd46af3..c32160c 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -2538,7 +2538,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: -0.017264389 + value: -0.017264387 objectReference: {fileID: 0} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z @@ -2558,19 +2558,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.968031 + value: 0.9680521 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.24655096 + value: 0.24655634 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.044709474 + value: 0.044250682 objectReference: {fileID: 0} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.011387202 + value: -0.01127035 objectReference: {fileID: 0} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_Name @@ -2662,11 +2662,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: -0.017264389 + value: -0.017264387 objectReference: {fileID: 0} - target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: 0.009297717 + value: 0.009297716 objectReference: {fileID: 0} - target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_XAxis.m_InvertInput @@ -2702,19 +2702,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.w - value: 0.9996364 + value: 0.99964887 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.x - value: 0.0047711134 + value: 0.004771158 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.y - value: 0.023366831 + value: 0.02294969 objectReference: {fileID: 0} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_LocalRotation.z - value: -0.0125841815 + value: -0.012359529 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} diff --git a/game/Assets/Scripts/Traps/FallawayFloor.cs b/game/Assets/Scripts/Traps/FallawayFloor.cs index b7099a7..cdd83a6 100644 --- a/game/Assets/Scripts/Traps/FallawayFloor.cs +++ b/game/Assets/Scripts/Traps/FallawayFloor.cs @@ -7,21 +7,21 @@ using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class FallawayFloor : MonoBehaviour { - // Speed at which the object moves towards the ground. + // // Speed at which the object moves towards the ground. public float speed; // Time it takes for ogjecct to begin moving towards the ground. public float fallAwayTime; - // Time taken for object to be destroyed. - public float destroyObjectTime; public Material dissolve; [SerializeField] private Renderer _renderer; - Rigidbody rb; - private Vector3 _initialPosition; + private Rigidbody rb; + private Vector3 initialPosition; private void Start() { + initialPosition = transform.position; + // Get Rigidbody component. rb = GetComponent(); } @@ -31,32 +31,23 @@ public class FallawayFloor : MonoBehaviour if (other.CompareTag("Player")) { // Start the Destroy floor coroutine and switch to the dissolve material. - StartCoroutine(DestroyFloor()); - // _renderer.material = dissolve; + StartCoroutine(Fall()); + _renderer.material = dissolve; } } - IEnumerator DestroyFloor() + private IEnumerator Fall() { - // Take fallAwayTime, speed, and destroyObjectTime from editor and apply + // wait a moment yield return new WaitForSeconds(fallAwayTime); + // fall rb.velocity = Vector3.down * speed; - - yield return new WaitForSeconds(destroyObjectTime); - - // Destroy(gameObject); } public void Reset() { - transform.position = _initialPosition; + transform.position = initialPosition; + rb.velocity = Vector3.zero; } } - -#if UNITY_EDITOR -public class FallawayFloorEditor : Editor -{ - -} -#endif