mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-26 02:00:54 -05:00
Merge branch 'DespawnBumpers'
This commit is contained in:
commit
37f15d10cc
|
|
@ -17,6 +17,18 @@ MonoBehaviour:
|
|||
PrefabHashGenerator: TempBumper
|
||||
AlwaysReplicateAsRoot: 0
|
||||
DontDestroyWithOwner: 0
|
||||
--- !u!114 &5019352696064972879
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8337410631319514038}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fefb30a560cee67419c8a02555b247b2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &3409778990194893120
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
32
Assets/Scripts/Environment/BumperDespawn.cs
Normal file
32
Assets/Scripts/Environment/BumperDespawn.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MLAPI;
|
||||
using MLAPI.Messaging;
|
||||
|
||||
public class BumperDespawn : NetworkBehaviour {
|
||||
|
||||
private float despawnTimer = 20f;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
// Only start the despawn timer on the host system
|
||||
if (!IsHost) { return; }
|
||||
|
||||
// Start the Despawn Timer
|
||||
StartCoroutine(DespawnTimer());
|
||||
}
|
||||
|
||||
IEnumerator DespawnTimer() {
|
||||
// Wait for the timer to complete
|
||||
yield return new WaitForSecondsRealtime(despawnTimer);
|
||||
|
||||
// Despawn the Bumper this is attached to
|
||||
DespawnMyselfServerRPC();
|
||||
}
|
||||
|
||||
[ServerRpc(RequireOwnership = false)]
|
||||
private void DespawnMyselfServerRPC() {
|
||||
gameObject.GetComponent<NetworkObject>().Despawn(true);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Environment/BumperDespawn.cs.meta
Normal file
11
Assets/Scripts/Environment/BumperDespawn.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fefb30a560cee67419c8a02555b247b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -119,7 +119,7 @@ public class GameHandler : NetworkBehaviour
|
|||
|
||||
[ServerRpc]
|
||||
private void DespawnCountdownServerRpc(ServerRpcParams serverRpcParams = default) {
|
||||
_countdownUI.GetComponent<NetworkObject>().Despawn();
|
||||
_countdownUI.GetComponent<NetworkObject>().Despawn(true);
|
||||
Destroy(_countdownUI);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user