quakeball/Assets/Scripts/Combat/Laser.cs
2020-08-08 08:27:52 +03:00

29 lines
877 B
C#

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);
}
}
}