Before updating to Windows 10 you may need to return your Pro license. More information here

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

avatar image

48 16 11 20

(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

avatar image

runevision ♦♦
9.9k 57 138 324

(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

avatar 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: 2825 times

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