[TASK] Spawn collectable ducks on the map when in range
This commit is contained in:
33
Assets/MagicArsenal/Demo/Scripts/MagicLoopScript.cs
Normal file
33
Assets/MagicArsenal/Demo/Scripts/MagicLoopScript.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace MagicArsenal {
|
||||
|
||||
public class MagicLoopScript : MonoBehaviour {
|
||||
|
||||
public GameObject chosenEffect;
|
||||
public float loopTimeLimit = 2.0f;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
PlayEffect();
|
||||
}
|
||||
|
||||
|
||||
public void PlayEffect()
|
||||
{
|
||||
StartCoroutine("EffectLoop");
|
||||
}
|
||||
|
||||
|
||||
IEnumerator EffectLoop()
|
||||
{
|
||||
GameObject effectPlayer = (GameObject) Instantiate(chosenEffect, transform.position, transform.rotation);
|
||||
|
||||
yield return new WaitForSeconds(loopTimeLimit);
|
||||
|
||||
Destroy (effectPlayer);
|
||||
PlayEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user