- Home /
Question by
The-Little-Guy · Aug 12, 2014 at 06:09 AM ·
particleslinerenderer
Electric/Energy Particle System
Is it possible to get this effect in unity? How can I do it? I assume it is a particle system and line renderer
https://www.youtube.com/watch?v=rR6aztrOe2s
Here is what I have so far. I have a start position and an end position. What Can I do to make random points between point A
and point B
? I am not sure what I should put in my Vector3()
so the points are random, but not too far from the line...
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(LineRenderer))]
public class Electricity : MonoBehaviour {
public int minPoints = 2;
public int maxPoints = 10;
public Transform startPosition;
public Transform endPosition;
protected LineRenderer lr;
protected int points;
// Use this for initialization
void Start () {
lr = GetComponent<LineRenderer>() as LineRenderer;
}
// Update is called once per frame
void Update () {
int i = 0;
points = Random.Range(minPoints, maxPoints);
lr.SetVertexCount(points);
while (i < points) {
Vector3 pos = new Vector3();
lr.SetPosition(i, pos);
i++;
}
}
}
Comment
you can get lightning particles free from the asset store in the Elementals particle pack.
Your answer
Follow this Question
Related Questions
How to stop linerender when it hits an object 2 Answers
Points attached to a prefab 0 Answers
Emit particles throughout a line/ray? 2 Answers
Laser Beam in Unity 0 Answers
LineRenderer or Particles 1 Answer