public override void CreateLightningBolt(LightningBoltParameters parameters) { if (meshHelper == null) { return; } Generations = parameters.Generations = Mathf.Clamp(Generations, 1, LightningSplineScript.MaxSplineGenerations); LightningBoltPathParameters pathParameters = parameters as LightningBoltPathParameters; sourcePoints.Clear(); PopulateSourcePoints(sourcePoints); if (sourcePoints.Count > 1) { if (Spline && sourcePoints.Count > 3) { pathParameters.Points = new List <Vector3>(sourcePoints.Count * Generations); LightningSplineScript.PopulateSpline(pathParameters.Points, sourcePoints, Generations, DistancePerSegmentHint, Camera); pathParameters.SmoothingFactor = (pathParameters.Points.Count - 1) / sourcePoints.Count; } else { pathParameters.Points = new List <Vector3>(sourcePoints); pathParameters.SmoothingFactor = 1; } base.CreateLightningBolt(pathParameters); } }
/// <summary> /// Triggers lightning that follows a set of points, rather than the standard lightning bolt that goes between two points. /// </summary> /// <param name="points">Points to follow</param> /// <param name="spline">Whether to spline the lightning through the points or not</param> public void Trigger(List <Vector3> points, bool spline) { if (points.Count < 2) { return; } Generations = Mathf.Clamp(Generations, 1, MaxSplineGenerations); LightningBoltParameters parameters = CreateParameters(); parameters.Points.Clear(); if (spline && points.Count > 3) { LightningSplineScript.PopulateSpline(parameters.Points, points, Generations, DistancePerSegmentHint, Camera); parameters.SmoothingFactor = (parameters.Points.Count - 1) / points.Count; } else { parameters.Points.AddRange(points); parameters.SmoothingFactor = 1; } base.CreateLightningBolt(parameters); CreateLightningBoltsNow(); }