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(

    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

48 15 10 18

(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 ♦♦
9.1k 53 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



Answers and Comments



asked: Feb 09, 2011 at 11:14 AM

Seen: 2432 times

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