//
// Procedural Lightning for Unity
// (c) 2015 Digital Ruby, LLC
// Source code may be used for personal or commercial projects.
// Source code may NOT be redistributed or sold.
//
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace DigitalRuby.ThunderAndLightning
{
///
/// Lightning bolt sphere shape script, creates lightning inside a sphere
///
public class LightningBoltShapeSphereScript : LightningBoltPrefabScriptBase
{
/// Radius inside the sphere where lightning can emit from
[Header("Lightning Sphere Properties")]
[Tooltip("Radius inside the sphere where lightning can emit from")]
public float InnerRadius = 0.1f;
/// Radius of the sphere
[Tooltip("Radius of the sphere")]
public float Radius = 4.0f;
#if UNITY_EDITOR
///
/// OnDrawGizmos
///
protected override void OnDrawGizmos()
{
base.OnDrawGizmos();
Gizmos.DrawWireSphere(transform.position, InnerRadius);
Gizmos.DrawWireSphere(transform.position, Radius);
}
#endif
///
/// Create a lightning bolt
///
/// Parameters
public override void CreateLightningBolt(LightningBoltParameters parameters)
{
Vector3 start = UnityEngine.Random.insideUnitSphere * InnerRadius;
Vector3 end = UnityEngine.Random.onUnitSphere * Radius;
parameters.Start = start;
parameters.End = end;
base.CreateLightningBolt(parameters);
}
}
}