This isn't a short post, it's not for the faint of heart, it's for people who want to learn to use the OB particle system. Don't tell me it's too long, if you can't be bothered to read the whole thing, why are you replying?
What is a particle effect?**
A particle effect in the Orange box engine is simply what it says on the tin, an effect composed of particles, which are rendered as sprites.
They have a variety of uses, and a lot of things can be done with them.
You can make weather, tracers, explosions, fire, blood, smoke, lasers, and more!
It’s very easy to construct a particle and spawn it in garrysmod through lua, if you know the basics.
They do have problems however.
How do I make one?
First things first, you go to your steam games menu, and right click Garrysmod.
Click properties, and there’s a button in there called launch options.
Add -tools to this field, and hit OK. Launch Gmod, and shortly after, you should be brought to the tools menu. Up in the top bar, there will be a button that says tools, click it, and press particle editor.
Hit file, new, and you can begin making effects!
You’ll be greeted with 4 windows.
The top left, contains your particles in the current file.
The top right, is the engine view (it should be greyed out, since you’re still in a menu)
The bottom right, contains your particle render window.
And the bottom left, is where the magic happens, it is your particle modification window.
So in the top left, you’ll see a button saying Create. Press it, and name the particle “glow_explosion1”
Down in the bottom left window, there should be stuff there already, we’ll ignore it for now. In the top left of the bottom left window, there is a dropdown box. This contains all the fields for your particle. The most important things are:
First, we’ll go to Renderers. In the blank space on the left, right click and select Add, then select Animated_sprites
That’s all you’ll need for now (you can mess around with the other render types later.)
Now we’ll skip operators, the next one down, and go past initializers, and go straight to emitters.
There’s a few emitter types. For our purposes, we’ll use emit_instantaneously. Add it the same way you added a renderer.
Now, we’ll go to initializers, unlike our previous 2 fields, initializers are much more numerous and varied, most do what they say on the tin, some are confusing, experiment!
For us, we’ll add a “position within sphere random” initializer, and tweak it a bit.
On the right, you’ll see a bunch of fields to modify, you could have tweaked such values in the renderers and emitters, but it’s best not to, until you know what you’re doing.
A position within sphere is important, because it spawns the particles at a CONTROL POINT (we’ll come back to these)
For now, find a field which says speed_max, set this to 50. Don’t worry if your particle doesn’t move yet, that’s normal, we’re going to operators next to make them move.
So go to operators, and before we add movement, we’ll make the particles ‘die’
Particles dying is important, if they don’t die, they constantly use CPU, even if they don’t render anything, or move. The computer still has to memorize their position, and the fact that they exist, so make sure at some point, all your particles DIE!
There are two main ways to kill a particle.
Right click and press add, and pick “Alpha fade and decay”
This fades a particle before killing it. You will notice your particles flicker occasionally now, this is the particles dying. When your render screen renders exactly 0 particles, it spawns a new wave of particles, so you may see the effect over and over again.
The other main way to kill a particle is a life span decay, which ignores alpha fading, and removes it instantaneously. This has it’s uses, but alpha fade usually looks better.
There are other operators to mess with, but the last one we’ll touch is “Movement basic”
Which, you guessed it, makes your particle move.
It has some options too, for gravity, drag etc.
Let’s add a movement basic, and set the drag to 0.1
Sometimes the editor will change your numbers from 0.1 to an incredibly lengthy decimal, like 0.1010104485123482
Don’t worry, this is normal, it doesn’t harm your particles, it’s something to do with how floats are handled, they’re basically the same number.
Now your effect should explode nicely.
The final major thing you need to know, is how to change the sprite.
Go to properties, and press the button next to “material”
A box will open and you can search for the material you want.
For now, copy “particle\particle_glow_01_additive.vmt” into the file path, and hit ok.
Save the file as whatever you want. You can keep several different effects in one file, and you can link them together using the Children tab.
Now you have an exploding glowy thing, and the rest is up to you. Good luck out there gordon.
How can I use them in lua?
There’s a few ways to spawn them.
I’ll be simple, because you’re all smart lua coders, so I reckon you can figure it out fairly easily.
Here are the commands:
The name is the name of your effect in the editor, in our case glow_explosion1, it is NOT the filename of your pcf file!
The entity is the entity you wish to attach the effect to.
attachtype is how you want the effect to attach to the entity (hence the name of the command, particleeffectATTACH)
You can put in a few things here:
_follow means the control point updates as the entity moves.
absorigin means the effect spawns at the entities origin, or centre.
Point means the effect follows an attachment you specify, with the last field.
The attachment is the ID of the attachment you wish the effect to follow, if it is using PATTACH_POINT.
If you don’t use this, default it to 0.
The next command is ParticleEffect(name,pos,angle,entity)
name is the same as last time, pos is the position you wish it to spawn at as a vector.
Angle is the LOCAL angle the effect uses. You have to specify whether a vector is local inside a particle effect itself sometimes, so it may seem like angle does nothing, but it does.
Entity is the same as before, the entity that spawns the effect.
PrecacheParticleSystem(name) is our second last command. It simply precaches a particle. If your particle isn’t spawning (Red Xes.) use this before you spawn it at some point, it should fix the issue.
This one instantly kills all particle effect spawners on an entity, it doesn’t actually kill particles that have been spawned however.
A control point is a piece of information sent by the game to an effect, it is a vector. Control point 0 always contains the effects origin, if the effect is attached to something, control point 0 moves with the entity.
Particles can be very expensive if they are large in size or number, or if they cover your screen, try to avoid this.
Particles cannot be put into addons.
You cannot define control points with lua.
You cannot reload or add new particle effects without restarting gmod, except by creating them with -tools. (IE, you can’t send a particle effect to a client and expect it to work until his gmod is restarted)
And that’s all you need to know to make effects. Experiment experiment experiment, make cool stuff