ParticleSystem gradually growing weird.

Started by
8 comments, last by GekkoCube 20 years, 8 months ago
I have a particlesystem, obviously, that is actually not my code. A bunch of the design and some code was borrowed from a demo i downloaded. You might have seen it, the design is something as follows: Base class is CParticlesystem. And there are derived classes, Fountain, Snow, Smoke, and WaterSprinkler. Anway, whenever i shoot a projectile at it comes in contact with something, I initiate a bunch of particles and let them go about their process...until they eventually run out of "life" or go below a certain Y point (below the terrain). But after 2 or 3 shots, the particles just dont look the same anymore. Rather than a nice big spray of particles like its suppose to be, they all go down very quickly, sometimes they dont appear because they go below the terrain level so quickly. It appears to me like gravity (which is applied to each individual particle) is pulling with a much greater force. My theory right now is that the time interval (elapsed time) is some how growing, which is causing one thing or several things to update at an undesireable rate. I can show code, but only if request, since there is alot of code in different files, thus unecessarily confusing the matter more. Please help me if you''ve experienced this sort of thing before. Thanks.
Advertisement
You need to have a timer and update your particles on an "x times per second" basis rather than every frame.
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
Thanks,

Im glad you mentioned and suggested that.
Right now I am updating every frame BUT i am incorporating the delta-T (elapsed time) into the updates.

I know what you are talking about...i will certainly try that.
But this brings a second question.

Should I be doing what you suggested, which is updating at every specified time elapsed, or by every frame with the delta-T incorporated in the calculation? Should these two essentially/visually do the same thing?
If I''ve got what you''re saying correct, then I think they should do the same thing. I.E. if an object moves 3 m/s, and they delta time for a certain frame is 0.25 seconds, then the object would move 3 * 0.25 meters that frame, and the gravity you apply would be affected by that same delta. I know 0.25 seconds is big for a frame''s delta, but I was just making a simple example.

peace and (trance) out

Mage
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
In most particle systems you have a position which is affected by velocity, and velocity which is affected by acceleration. If this particle system works the same way, then it sounds like memory from past particles is being used for future particles and either velocity or acceleration aren''t being reset.
thanks.

SOMEHOW, and i dont know why or how, the timing issue seems to have remedied everything relating to the particle system.

I do have one more question now that you''ve mentioned this...
i do have a velocity and acceleration variables in my particle system, but only because that is the way the author wrote it.

This confused me at first but, isn''t having acceleration kinda redundant if i have a velocity vector?
quote:Original post by GekkoCube
This confused me at first but, isn''t having acceleration kinda redundant if i have a velocity vector?

velocity is the speed and direction the object is moving.
acceleration is the change in velocity per second.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
right, if you''re velocity is 12m/s in the positive x direction and your acceleration is -2m/s*s in the x direction, then the first second you modify the object''s position +12m in the x direction and the velociy -1 m/s in the x direction leaving you with a velocity +10m/s. Velocity affects position, acceleration affects velocity.

peace and (trance) out

Mage
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
Makes sense.
Make sure you reset ALL fields in your ParticleReset() function (or whatever you call it).

I think you are, but use the elapsed time to multiply by the velocity to get a steady rate that doesn''t jump.

Play around with the values. It took me a while to get numbers that worked just the way I wanted them.

Good Luck!

This topic is closed to new replies.

Advertisement