42 lines
935 B
C#
42 lines
935 B
C#
using UnityEngine;
|
|
|
|
namespace Artngame.TEM
|
|
{
|
|
public class AddLightning : MonoBehaviour
|
|
{
|
|
public GameObject lightningObj;
|
|
|
|
private float timer;
|
|
|
|
public float timeUntilLightningMin = 1f;
|
|
|
|
public float timeUntilLightningMax = 5f;
|
|
|
|
private float timeUntilLightning = 1f;
|
|
|
|
public bool placeOnTRansform;
|
|
|
|
public float yOffset;
|
|
|
|
private void Update()
|
|
{
|
|
timer += Time.deltaTime;
|
|
if (timer > timeUntilLightning)
|
|
{
|
|
timer = 0f;
|
|
timeUntilLightning = Random.Range(timeUntilLightningMin, timeUntilLightningMax);
|
|
float num = 500f;
|
|
float x = Random.Range(0f - num, num);
|
|
float z = Random.Range(0f - num, num);
|
|
float y = 230f;
|
|
Vector3 position = new Vector3(x, y, z);
|
|
if (placeOnTRansform)
|
|
{
|
|
position = base.transform.position + new Vector3(0f, yOffset, 0f);
|
|
}
|
|
Object.Instantiate(lightningObj, position, Quaternion.identity).transform.parent = base.transform;
|
|
}
|
|
}
|
|
}
|
|
}
|