animation and audio event on falling platforms

This commit is contained in:
Cat Flynn 2021-03-17 18:31:33 +00:00
parent 44e55b22fe
commit 9037fd264c
5 changed files with 114 additions and 5 deletions

View File

@ -1,12 +1,12 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!65 &9034355455690887775 --- !u!65 &8195222329856083248
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4864755999650917293} m_GameObject: {fileID: 3548415475167668665}
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_IsTrigger: 0 m_IsTrigger: 0
m_Enabled: 1 m_Enabled: 1
@ -46,6 +46,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 5244658790847279383} - {fileID: 5244658790847279383}
- {fileID: 4212362909712282371}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: -36.672, z: 0} m_LocalEulerAnglesHint: {x: 0, y: -36.672, z: 0}
@ -87,6 +88,7 @@ MonoBehaviour:
dissolve: {fileID: 2100000, guid: 98767dd77414bad44b23ef5332c1d8f1, type: 2} dissolve: {fileID: 2100000, guid: 98767dd77414bad44b23ef5332c1d8f1, type: 2}
_renderer: {fileID: 6378198502367496824} _renderer: {fileID: 6378198502367496824}
_settings: {fileID: 11400000, guid: 36275776eda5c8249bf45e01721afe36, type: 2} _settings: {fileID: 11400000, guid: 36275776eda5c8249bf45e01721afe36, type: 2}
_graphics: {fileID: 4864755999650917293}
--- !u!54 &980120856895548943 --- !u!54 &980120856895548943
Rigidbody: Rigidbody:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -131,6 +133,97 @@ MonoBehaviour:
m_StringArgument: m_StringArgument:
m_BoolArgument: 0 m_BoolArgument: 0
m_CallState: 2 m_CallState: 2
--- !u!1001 &4467545279269377256
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 8144920974147422729}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalScale.x
value: 1.0634918
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalScale.y
value: 1.3920045
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalScale.z
value: 1.0634918
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalPosition.x
value: 0.958
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalPosition.z
value: 0.974
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7511558181221131132, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7511558181221131132, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 22a733893c7f0bc48b61d6a462964442, type: 2}
- target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_Name
value: Collision
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
--- !u!1 &3548415475167668665 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
m_PrefabInstance: {fileID: 4467545279269377256}
m_PrefabAsset: {fileID: 0}
--- !u!4 &4212362909712282371 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
m_PrefabInstance: {fileID: 4467545279269377256}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &5711263752094586620 --- !u!1001 &5711263752094586620
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -200,7 +293,7 @@ PrefabInstance:
objectReference: {fileID: 2100000, guid: 22a733893c7f0bc48b61d6a462964442, type: 2} objectReference: {fileID: 2100000, guid: 22a733893c7f0bc48b61d6a462964442, type: 2}
- target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3} - target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Floor_B (13) value: Graphics
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3} - target: {fileID: 919132149155446097, guid: 803c82d4ce9f809448a55cba1adec183, type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive

View File

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using DG.Tweening;
using NaughtyAttributes; using NaughtyAttributes;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@ -71,6 +72,7 @@ public class Bootstrap : MonoBehaviour
private void Awake() private void Awake()
{ {
_instance = this; _instance = this;
DOTween.Init();
if ( _debugMode ) if ( _debugMode )
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using DG.Tweening;
using Ktyl.Util; using Ktyl.Util;
using UnityEngine; using UnityEngine;
@ -15,6 +16,7 @@ public class FallawayFloor : MonoBehaviour
[SerializeField] private Renderer _renderer; [SerializeField] private Renderer _renderer;
[SerializeField] private TrapSettings _settings; [SerializeField] private TrapSettings _settings;
[SerializeField] private GameObject _graphics;
private Rigidbody rb; private Rigidbody rb;
private Vector3 initialPosition; private Vector3 initialPosition;
@ -48,7 +50,10 @@ public class FallawayFloor : MonoBehaviour
private IEnumerator Fall() private IEnumerator Fall()
{ {
// TODO: trigger shake, maybe particle effect? _graphics.transform.DOShakePosition(
fallAwayTime,
_settings.FallawayFloor.ShakeStrength);
FMODUnity.RuntimeManager.PlayOneShot(_settings.FallawayFloor.FMODEvent);
_triggered = true; _triggered = true;

View File

@ -10,13 +10,20 @@ public class TrapSettings : ScriptableObject
[Serializable] [Serializable]
public struct FallawayFloorSettings public struct FallawayFloorSettings
{ {
public string FMODEvent => _fmodEvent;
[SerializeField] private string _fmodEvent;
[Header("Platform respawning")]
// how long it takes for falling platforms to respawn while the player is safe // how long it takes for falling platforms to respawn while the player is safe
[SerializeField] private SerialFloat _respawnTime; [SerializeField] private SerialFloat _respawnTime;
// how long the player has currently been safe for. -1 while the player is not // how long the player has currently been safe for. -1 while the player is not
// in a safe zone // in a safe zone
[SerializeField] private SerialFloat _safeTime; [SerializeField] private SerialFloat _safeTime;
public bool CanRespawn => _safeTime > _respawnTime; public bool CanRespawn => _safeTime > _respawnTime;
public float ShakeStrength => _shakeStrength;
[Header("Animation")]
[SerializeField] private float _shakeStrength;
} }
public FallawayFloorSettings FallawayFloor => _fallawayFloor; public FallawayFloorSettings FallawayFloor => _fallawayFloor;
[SerializeField] private FallawayFloorSettings _fallawayFloor; [SerializeField] private FallawayFloorSettings _fallawayFloor;

View File

@ -13,5 +13,7 @@ MonoBehaviour:
m_Name: Trap Settings m_Name: Trap Settings
m_EditorClassIdentifier: m_EditorClassIdentifier:
_fallawayFloor: _fallawayFloor:
_fmodEvent: event:/Environment/Traps/FallingPlatform
_respawnTime: {fileID: 11400000, guid: 1d2951ab5083d4d48a319ff00a9eb8bd, type: 2} _respawnTime: {fileID: 11400000, guid: 1d2951ab5083d4d48a319ff00a9eb8bd, type: 2}
_safeTime: {fileID: 11400000, guid: 27c10a061baeec8469e96d4f995c1445, type: 2} _safeTime: {fileID: 11400000, guid: 27c10a061baeec8469e96d4f995c1445, type: 2}
_shakeStrength: 0.1