quakeball/Assets/Scripts/Combat/Laser.cs

29 lines
877 B
C#
Raw Permalink Normal View History

2020-08-08 07:23:23 +02:00
using UnityEngine;
namespace NeonTea.Quakeball.Combat {
[RequireComponent(typeof(ParticleSystem))]
public class Laser : MonoBehaviour {
public Vector3 From;
public Vector3 To;
private ParticleSystem.Particle[] particles = new ParticleSystem.Particle[2];
private ParticleSystem ParticleSystem;
private bool Initialized = false;
private void Start() {
ParticleSystem = GetComponent<ParticleSystem>();
ParticleSystem.Play();
}
private void Update() {
ParticleSystem.GetParticles(particles);
if (ParticleSystem.particleCount > 0 && !Initialized) {
particles[1].position = To;
Initialized = true;
}
particles[0].position = From;
ParticleSystem.SetParticles(particles);
}
}
}