Jump to content

  • Log In with Google      Sign In   
  • Create Account


creating Particle system. problem with the spread


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 henrykl   Members   -  Reputation: 117

Like
0Likes
Like

Posted 17 June 2012 - 06:26 AM

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

Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

Posted 17 June 2012 - 08:23 AM

  • When using rand() like that, you should actually do it like: static_cast<float>(rand()) / static_cast<float>(RAND_MAX + 1.0f) * Spreadrate. See this on why.
  • There isn't anything obvious from this... You're sure that DegreesToRadians() and Vector2D_Rotate() 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 srand() once (and only once) in your program before you can start calling rand().

[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 henrykl   Members   -  Reputation: 117

Like
0Likes
Like

Posted 17 June 2012 - 11:21 AM

Thank you so much the static cast was exactly what i needed.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS