x


How do you make random local velocity for particles?

I'm pretty new to Unity and found I couldn't make the particle effect I was going for (using a particle emitter component) without random local velocity. My first thought was to make a script adding values which would translate to world values then be added to the existing rndVelocity options. I can't figure out how to do it though. This is what I tried:

var rndLocalVelX : float = 0;
var rndLocalVelY : float = 0;
var rndLocalVelZ : float = 0;
var particlez : ParticleEmitter;
var relativeDirection : Vector3;

function Start ()
{
    var randomAdd : Vector3; 
    randomAdd = Vector3(
        rndLocalVelX, 
        rndLocalVelY, 
        rndLocalVelZ);

    relativeDirection = transform.TransformDirection(randomAdd);

    particlez = GetComponent(ParticleEmitter);

    //adding a random value to local velocity:
    particlez.rndVelocity += relativeDirection;
}
more ▼

asked Feb 09, 2011 at 11:14 AM

dustingunn gravatar image

dustingunn
48 15 10 17

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

2 answers: sort voted first

I don't understand what you're trying to do, but anyway, the variable called Rnd Velocity is already local random velocity. So you can just set that value directly.

more ▼

answered Feb 09, 2011 at 12:04 PM

runevision gravatar image

runevision ♦♦
9k 52 77 134

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

do you need to add positive and negative velocity? If so, use Random.Range(min, max)

randomAdd = Vector3(Random.Range(-rndLocalVelX, rndLocalVelX), Random.Range(-rndLocalVelY, rndLocalVelY), Random.Range(-rndLocalVelZ, rndLocalVelZ));

you would set this as Velocity instead of rndVelocity ofcourse

more ▼

answered Feb 09, 2011 at 12:42 PM

Tobs 1 gravatar image

Tobs 1
42 1

(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:

x980
x969
x196
x150
x57

asked: Feb 09, 2011 at 11:14 AM

Seen: 2286 times

Last Updated: Feb 09, 2011 at 12:00 PM