Update Self Destruct Script
This commit is contained in:
parent
ad095108d1
commit
05311b5b2d
@ -1,29 +1,37 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class TimedSelfDestruct : MonoBehaviour
|
||||
public class TimedSelfDestructWithTimer : MonoBehaviour
|
||||
{
|
||||
|
||||
// After this time, the object will be destroyed
|
||||
public float timeToDestruction;
|
||||
// After this time, the object will be destroyed
|
||||
public float timeToDestruction;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
Invoke("DestroyMe", timeToDestruction);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
//Invoke("DestroyMe", timeToDestruction);
|
||||
}
|
||||
|
||||
// Update is called every frame, if the MonoBehaviour is enabled.
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (timeToDestruction > 0)
|
||||
{
|
||||
timeToDestruction -= Time.deltaTime;
|
||||
GetComponentInChildren<TextMesh>().text = Mathf.Abs(timeToDestruction).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
DestroyMe();
|
||||
}
|
||||
}
|
||||
|
||||
// This function will destroy this object :(
|
||||
void DestroyMe()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
// This function will destroy this object :(
|
||||
void DestroyMe()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
|
||||
// Bye bye!
|
||||
}
|
||||
// Bye bye!
|
||||
}
|
||||
}
|
||||
|
11
Unity-Files/Assets/Scripts/Gameplay/TimedSelfDestructWithTimer.cs.meta
generated
Normal file
11
Unity-Files/Assets/Scripts/Gameplay/TimedSelfDestructWithTimer.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fb007fc909a54d4e9f2700296b8898d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
x
Reference in New Issue
Block a user