reset falling floor trap position on player respawn

This commit is contained in:
Cat Flynn 2021-03-10 18:26:33 +00:00
parent 762bbf6486
commit d5de30107f
3 changed files with 24 additions and 33 deletions

View File

@ -82,7 +82,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3} m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
speed: 3 speed: 10
fallAwayTime: 1 fallAwayTime: 1
destroyObjectTime: 0 destroyObjectTime: 0
dissolve: {fileID: 2100000, guid: 98767dd77414bad44b23ef5332c1d8f1, type: 2} dissolve: {fileID: 2100000, guid: 98767dd77414bad44b23ef5332c1d8f1, type: 2}

View File

@ -2538,7 +2538,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: -0.017264389 value: -0.017264387
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
@ -2558,19 +2558,19 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
value: 0.968031 value: 0.9680521
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0.24655096 value: 0.24655634
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0.044709474 value: 0.044250682
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: -0.011387202 value: -0.01127035
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_Name propertyPath: m_Name
@ -2662,11 +2662,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: -0.017264389 value: -0.017264387
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0.009297717 value: 0.009297716
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_XAxis.m_InvertInput propertyPath: m_XAxis.m_InvertInput
@ -2702,19 +2702,19 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
value: 0.9996364 value: 0.99964887
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0.0047711134 value: 0.004771158
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0.023366831 value: 0.02294969
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: -0.0125841815 value: -0.012359529
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}

View File

@ -7,21 +7,21 @@ using UnityEngine;
[RequireComponent(typeof(Rigidbody))] [RequireComponent(typeof(Rigidbody))]
public class FallawayFloor : MonoBehaviour 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; public float speed;
// Time it takes for ogjecct to begin moving towards the ground. // Time it takes for ogjecct to begin moving towards the ground.
public float fallAwayTime; public float fallAwayTime;
// Time taken for object to be destroyed.
public float destroyObjectTime;
public Material dissolve; public Material dissolve;
[SerializeField] private Renderer _renderer; [SerializeField] private Renderer _renderer;
Rigidbody rb; private Rigidbody rb;
private Vector3 _initialPosition; private Vector3 initialPosition;
private void Start() private void Start()
{ {
initialPosition = transform.position;
// Get Rigidbody component. // Get Rigidbody component.
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
@ -31,32 +31,23 @@ public class FallawayFloor : MonoBehaviour
if (other.CompareTag("Player")) if (other.CompareTag("Player"))
{ {
// Start the Destroy floor coroutine and switch to the dissolve material. // Start the Destroy floor coroutine and switch to the dissolve material.
StartCoroutine(DestroyFloor()); StartCoroutine(Fall());
// _renderer.material = dissolve; _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); yield return new WaitForSeconds(fallAwayTime);
// fall
rb.velocity = Vector3.down * speed; rb.velocity = Vector3.down * speed;
yield return new WaitForSeconds(destroyObjectTime);
// Destroy(gameObject);
} }
public void Reset() public void Reset()
{ {
transform.position = _initialPosition; transform.position = initialPosition;
rb.velocity = Vector3.zero;
} }
} }
#if UNITY_EDITOR
public class FallawayFloorEditor : Editor
{
}
#endif