Jump to content
  • Advertisement

Archived

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

Pogo187

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!