Sign in to follow this  
henrykl

creating Particle system. problem with the spread

Recommended Posts

henrykl    117
Hello all,

i have been working on a particle system for a while now, but its just not coming together the way i need it too. i am at my wits end with it. the main prblem i have is that my spread doesnt spread at all, it lingers trailing behind the object its attached to.

heres how i start it

p->SetDirection ( Vector2D_Rotate(direction,DegreesToRadians(float(rand() % int(Spreadrate)))));
pos.fX =(float) m_vStartPosX;
pos.fY =(float) m_vStartPosY;
p->setPosition(pos);

and its update



m_vPosition.fX += Direction.fX * m_vVelocity.fX * dt;
m_vPosition.fY += Direction.fY * m_vVelocity.fY * dt;

any help would be much appreciated

Share this post


Link to post
Share on other sites
Cornstalks    7030
[list=1]
[*]When using [font=courier new,courier,monospace]rand()[/font] like that, you should actually do it like: [font=courier new,courier,monospace]static_cast<float>(rand()) / static_cast<float>(RAND_MAX + 1.0f) * Spreadrate[/font]. [url="http://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator"]See this on why[/url].
[*]There isn't anything obvious from this... You're sure that [font=courier new,courier,monospace]DegreesToRadians()[/font] and [font=courier new,courier,monospace]Vector2D_Rotate()[/font] work properly and are returning the correct values? Step through it with a debugger and find out what these functions are receiving as parameters and what they're returning, and make sure they're correct. Make sure your randomness is working correctly.
[*]Are you initializing the random library properly? You have to call [font=courier new,courier,monospace]srand()[/font] once (and only once) in your program before you can start calling [font=courier new,courier,monospace]rand()[/font].
[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this