x


Setting particle position does not appear work

It seems that I cannot set a particle's position. This script creates particles but leaves them all at the emitter's origin.

I tried to add a Debug.Log(p.position) after the PlaceParticle call and it seemed to be spouting off correct values. But I end up with thousands of particles in the same exact spot on screen when this runs.

private var     density : float = 0.5;
private var     height  : float = 100;

function Start() {
    yield WaitForSeconds(0.1);
    var radius = Stage.stage.radius * 1.5;
    var area   = Mathf.PI * radius * radius;
    var count  = density * area;

    particleEmitter.Emit(count);

    for (var p:Particle in particleEmitter.particles) {
        PlaceParticle(p, radius);
    }
}

function PlaceParticle (particle : Particle, radius : float) {
    particle.position = transform.position + Vector3(
        Random.value * radius,
        Random.value * radius,
        Random.value * height
    );

    if (particle.position.magnitude > radius) {
        PlaceParticle(particle, radius);
    }
}

Any ideas?

more ▼

asked Apr 27 '10 at 12:09 AM

Squeegy gravatar image

Squeegy
235 8 10 21

(comments are locked)
10|3000 characters needed characters left

3 answers: sort newest

This is a little old, but the issue is that you didn't apply the particles array back to the emitter. It's not passed by reference.

When you're done:

emitter.particles = modified_particles;
more ▼

answered May 22 '11 at 04:48 AM

UltimateBrent gravatar image

UltimateBrent
149 1 2 6

(comments are locked)
10|3000 characters needed characters left

I don't see you setting Particle.velocity anywhere. Would that have a bearing on your problem?

more ▼

answered Apr 27 '10 at 12:14 AM

e.bonneville gravatar image

e.bonneville
5.7k 100 116 165

The particles shouldn't move or expire. The game object they attached doesn't have Particle Animator ebcause they should be completely static. I just want to generate a bunch of particles randomly with a cylinder.

Apr 27 '10 at 12:31 AM Squeegy

Oh... Got it - sorry.

Apr 27 '10 at 12:37 AM e.bonneville
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5099
x644

asked: Apr 27 '10 at 12:09 AM

Seen: 1521 times

Last Updated: May 22 '11 at 04:48 AM