Merge branch 'bug/trap-floor-no-resest' into 'main'
Bug/trap floor no resest Closes #74 See merge request kernel-panic/revival!39
This commit is contained in:
commit
c04bdee120
|
@ -26,6 +26,7 @@ GameObject:
|
||||||
- component: {fileID: 980120856895548940}
|
- component: {fileID: 980120856895548940}
|
||||||
- component: {fileID: 980120856895548939}
|
- component: {fileID: 980120856895548939}
|
||||||
- component: {fileID: 980120856895548943}
|
- component: {fileID: 980120856895548943}
|
||||||
|
- component: {fileID: 3536778402394572832}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: FallawayFloor
|
m_Name: FallawayFloor
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -81,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}
|
||||||
|
@ -100,8 +101,36 @@ Rigidbody:
|
||||||
m_UseGravity: 0
|
m_UseGravity: 0
|
||||||
m_IsKinematic: 0
|
m_IsKinematic: 0
|
||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 122
|
||||||
m_CollisionDetection: 0
|
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
|
--- !u!1001 &5711263752094586620
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -2538,11 +2538,11 @@ 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.017264403
|
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
|
||||||
value: 0.009297725
|
value: 0.009297717
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
|
@ -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.9680315
|
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.24655113
|
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.044697873
|
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.011384248
|
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.9996367
|
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.0047710985
|
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.023356276
|
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.012578499
|
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}
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
[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 void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
initialPosition = transform.position;
|
||||||
|
|
||||||
// Get Rigidbody component.
|
// Get Rigidbody component.
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
}
|
}
|
||||||
|
@ -28,18 +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);
|
||||||
rb.velocity = Vector3.down * speed;
|
|
||||||
yield return new WaitForSeconds(destroyObjectTime);
|
|
||||||
|
|
||||||
Destroy(gameObject);
|
// fall
|
||||||
|
rb.velocity = Vector3.down * speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
transform.position = initialPosition;
|
||||||
|
rb.velocity = Vector3.zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue