- Home /
Question by
$$anonymous$$ · Aug 02, 2013 at 09:50 AM ·
particlesformparabolic
How to make parabolic particle form?
So is there any way to create particle form like this? Thanks!
без имени-2-восстановлено.png
(61.7 kB)
Comment
Best Answer
Answer by robertbu · Aug 02, 2013 at 08:35 PM
I've done very little scripting with Particles (beyond turning them on an off), so this was an interesting question for me. Here is a script that uses a Mathf.Sin() to create a wave as you've outlined.
var magnitude = 1.0;
var period = 2.0;
var maxParticles = 1000;
private var particles : ParticleSystem.Particle[];
private var ps : ParticleSystem;
function Start () {
ps = particleSystem;
particles = new ParticleSystem.Particle[maxParticles];
}
function Update() {
if (ps.particleCount > particles.Length) {
particles = new ParticleSystem.Particle[ ps.particleCount];
}
ps.GetParticles(particles);
for(var i = 0; i < ps.particleCount; i++) {
var dist = particles[i].position.x - transform.position.x;
particles[i].position.y = Mathf.Sin((dist % period) / period * 2.0 * Mathf.PI) * magnitude;
}
ps.SetParticles(particles, ps.particleCount);
}
Apparently you cannot get the maximum number of particles in script, so I use a variable plus some code that will resize the array if the variable is wrong.
particlesine.jpg
(24.3 kB)
Your answer
![](https://koobas.hobune.stream/wayback/20220613111417im_/https://answers.unity.com/themes/thub/images/avi.jpg)