Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / 3D Particle System [SIMPLE]

Author
Message
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 17th Aug 2016 15:47
Hi all!

So I know that Baxslash has come up with a very cool system for this, but I thought I'd share what I came up with tonight for those wanting to implement a very simplistic 3D particles system into their game. The code is pretty simple. It only supports up to 1000 particles at a time, but that's easily expandable. I just don't have a need for more than that in my game.

So firstly, there's the global declaration to hold the particle info:



Then, there's the manager function. Stick a call to this in your main game loop to manage any existing particles:



Then, there is of course the function to produce a particle. I'm sure you could also use this to create some sort of "particle source" system, too.



Creating a particle with this should be pretty self explanatory, but here are the details:

ParticleX# - X starting position of the particle in the game world
ParticleY# - Y starting position of the particle in the game world
ParticleZ# - Z starting position of the particle in the game world
Speed# - The speed at which the particle moves
Size# - The size of the particle billboard
angleX# - X angle of direction at which the particle travels (it will always face the camera)
angleY# - Y angle of direction at which the particle travels (it will always face the camera)
angleZ# - Z angle of direction at which the particle travels (it will always face the camera)
Spin# - The starting rotation of the particle. Spin speed is constant but that can be modified if you really want to control the spin speed
DriftAngle - The amount of chaos in the projection angle of the particle. Set this to a big number to create "puffs" of smoke, or a low number to create a "jet" stream of particles
Gravity# - Positive numbers make particles sink, negative numbers make particles float
Life - How many ticks the particle will live for before de-spawning, making room for future particles
TextureIndex - The image reference number of the texture file to use for this particle

Anyways, I know it's very simple but I hope someone can get some use out of it!
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 19th Aug 2016 00:55
Looks decent so far. I'd have simplified it just a bit, but that's my own preference when it comes to building my own functions. My only suggestion is to change your particle array, make a particle type object with the 8 details and than declare your array as the type object. Example:



Good luck!
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 19th Aug 2016 03:08
Sounds good!

Login to post a reply

Server time is: 2024-04-20 14:18:41
Your offset time is: 2024-04-20 14:18:41