Update Self Destruct Script
This commit is contained in:
parent
ad095108d1
commit
05311b5b2d
@ -1,22 +1,30 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class TimedSelfDestruct : MonoBehaviour
|
public class TimedSelfDestructWithTimer : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
// After this time, the object will be destroyed
|
// After this time, the object will be destroyed
|
||||||
public float timeToDestruction;
|
public float timeToDestruction;
|
||||||
|
|
||||||
|
|
||||||
void Start ()
|
void Start()
|
||||||
{
|
{
|
||||||
Invoke("DestroyMe", timeToDestruction);
|
//Invoke("DestroyMe", timeToDestruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called every frame, if the MonoBehaviour is enabled.
|
// Update is called every frame, if the MonoBehaviour is enabled.
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
if (timeToDestruction > 0)
|
||||||
|
{
|
||||||
|
timeToDestruction -= Time.deltaTime;
|
||||||
|
GetComponentInChildren<TextMesh>().text = Mathf.Abs(timeToDestruction).ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DestroyMe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will destroy this object :(
|
// This function will destroy this object :(
|
||||||
|
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