# How do you make random local velocity for particles?

 0 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 '11 at 11:14 AM dustingunn 31 ● 3 ● 4 ● 4 runevision ♦♦ 8.1k ● 29 ● 46 ● 112 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 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 '11 at 12:04 PM runevision ♦♦ 8.1k ● 29 ● 46 ● 112 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 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 '11 at 12:42 PM Tobs 1 11 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x637
x571
x133
x109
x49

asked: Feb 09 '11 at 11:14 AM

Seen: 1356 times

Last Updated: Feb 09 '11 at 12:00 PM