#### Archived

This topic is now archived and is closed to further replies.

# Vector based on rotation

This topic is 5558 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

In a particle system I have created, it inherits the velocity from the object that created it. The problem is that if I use the same velocity as the object traveling, it just becomes a single particle traveling in the same exact direction, if I vary the velocity by multiplying it with a random float, it creates a nice form of variation. Unfortunatly, the main problem is that when I do this, and just travel on the x axis, it creates a nice distinction between the particles and creates a straight beam. If I fire it North-West for example, it creates an expanding square which doesn''t at all look like a beam. Unfortunatly, with my limited knowledge of maths I cannot solve this. Any help is appreciated, thanks.

##### Share on other sites
I think the problem is that you are multiplyinf the x, y and z coordinates with different random values. you should multiply all 3 coordinates by the same random value to preserve the direction

My Site

##### Share on other sites
Ugh, so simple. Don''t know why I didn''t think of that before :/
Thanks

##### Share on other sites
Along the same principal, I need to create some randomness in the particles, without making it expand in a square. I''m trying to create a ''spread'' effect where the particles have their velocities randomly changed based on the rotation. How would I do this?

Thanks

##### Share on other sites
You could do this:

1. store the vectors magnitude
2. add a random number to each vector component
3. normalize the vector to have its original magnitude

This won''t give you a completely even spread, but I think it will look alright.

One way to get an even spread would be to use atan to find the angles of the vector, add a random component to the angle, then go back and use the angle to get the new vector.

Here''s a way to get an even spread:
1. store vectors magnitude
2. get 3 random numbers
3. normalize those 3 numbers as a vector, so that it has some constant magnitude of your choosing (higher mag = more spread)
4. add that vector to the first vector
5. normalize the first vector to its original magnitude

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×