Skip to content

Commit f14c987

Browse files
author
Ricardo J. Mendez
committed
Improved lightning
1 parent 48711a5 commit f14c987

35 files changed

+21
-21
lines changed

Assets/Scenes/Lightning.unity

191 Bytes
Binary file not shown.

Assets/Scripts

Submodule Scripts updated from 7aa1c08 to 8a63355

Assets/Sources/LightningBolt.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
Contributed by Jonathan Czeck
44
*/
55
using UnityEngine;
6+
using UnitySteer;
67
using UnitySteer.Vehicles;
78
using System.Collections;
89

910
public class LightningBolt : MonoBehaviour
1011
{
11-
public Transform target;
12+
public WanderBehavior target;
1213
public int zigs = 100;
1314
public float speed = 1f;
1415
public float scale = 1f;
@@ -31,34 +32,33 @@ void Start()
3132
vehicles = new Rope[particles.Length];
3233
RandomizeParticlePositions();
3334

34-
for(int i = 0; i < particles.Length; i++)
35+
for(int i = particles.Length - 1; i >= 0; i--)
3536
{
36-
// Transform t = new Transform();
3737
vehicles[i] = new Rope(particles[i].position, 0.1f, null, null);
3838

3939
vehicles[i].Mass = 0.1f;
4040
vehicles[i].Radius = 0.05f;
41-
vehicles[i].MaxSpeed = 5f;
42-
vehicles[i].MaxForce = 10f;
43-
}
44-
for(int i = 0; i < particles.Length - 1; i++)
45-
{
46-
// Transform t = new Transform();
47-
vehicles[i].Next = vehicles[i+1];
48-
if (i > 0)
49-
{
50-
vehicles[i].Previous = vehicles[i-1];
51-
}
41+
vehicles[i].MaxSpeed = 10f;
42+
vehicles[i].MaxForce = 5;
43+
44+
if (i < particles.Length - 1)
45+
{
46+
vehicles[i].Next = vehicles[i+1];
47+
vehicles[i+1].Previous = vehicles[i];
48+
}
49+
else
50+
{
51+
vehicles[i].Next = target.Wanderer;
52+
}
53+
5254
}
5355
}
5456

5557
void Update ()
5658
{
57-
// RandomizeParticlePositions(true);
58-
RandomizeParticlePositions(particles.Length - 1);
59-
// Randomize the position of the last particle only
60-
vehicles[particles.Length-1].Position = particles[particles.Length-1].position;
61-
for(int i = 0; i < particles.Length -1; i++)
59+
//RandomizeParticlePositions(false);
60+
61+
for(int i = particles.Length - 1; i >= 0; i--)
6262
{
6363
vehicles[i].Position = particles[i].position;
6464
vehicles[i].update(Time.time, Time.deltaTime);
@@ -107,7 +107,7 @@ void RandomizeParticlePositions(int startIndex, bool isOffset)
107107
for (int i = startIndex; i < particles.Length; i++)
108108
{
109109
Vector3 position = isOffset ? particles[i].position
110-
: Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
110+
: Vector3.Lerp(transform.position, target.Wanderer.Position, oneOverZigs * (float)i);
111111
Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
112112
noise.Noise(timey + position.x, timey + position.y, timey + position.z),
113113
noise.Noise(timez + position.x, timez + position.y, timez + position.z));
0 Bytes
Binary file not shown.
563 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

Library/assetDatabase3

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
40 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
264 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)