[TASK] Spawn collectable ducks on the map when in range

This commit is contained in:
2019-08-19 00:36:56 +02:00
parent 98219ecfef
commit 279c5fbbbe
2270 changed files with 6269477 additions and 182 deletions

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using System.Collections;
namespace MagicArsenal
{
public class MagicLightFade : MonoBehaviour
{
[Header("Seconds to dim the light")]
public float life = 0.2f;
public bool killAfterLife = true;
private Light li;
private float initIntensity;
// Use this for initialization
void Start()
{
if (gameObject.GetComponent<Light>())
{
li = gameObject.GetComponent<Light>();
initIntensity = li.intensity;
}
else
print("No light object found on " + gameObject.name);
}
// Update is called once per frame
void Update()
{
if (gameObject.GetComponent<Light>())
{
li.intensity -= initIntensity * (Time.deltaTime / life);
if (killAfterLife && li.intensity <= 0)
Destroy(gameObject);
}
}
}
}