Particles Thread: All you need to know

**


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:
Renderers
Emitters
Initializers
Operators

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:
ParticleEffectAttach(name,attachtype,entity,attachment)
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:
PATTACH_ABSORIGIN_FOLLOW
PATTACH_ABSORIGIN
PATTACH_POINT_FOLLOW
PATTACH_POINT

_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.

Finally, Entity:StopParticles()
This one instantly kills all particle effect spawners on an entity, it doesn’t actually kill particles that have been spawned however.

Control Points
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.

Limitations!
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 :slight_smile:

I actually needed this for something I’m working on :slight_smile: Much appreciated!

If you run into any problems, feel free to ask, I know what basically every feature of the editor does.

EDIT: Except emit_noise.
I still cant figure out how to make that work :S

When you say “Particles cannot be put into addons.”, then say “IE, you can’t send a particle effect to a client and expect it to work until his gmod is restarted”, that confuses me. Are you saying, I can’t put the particles into addon format, but I can send them via resourse.addFile?

This may sound stupid. It’s 5:00am and I’m tired so I just may not be thinking right.

If you put them in an addon, they don’t get loaded.
If you send them to a client, he WILL get the files, and they will be loaded, but not until next time he boots Gmod.

Do we need to worry about the particle_manifest when we send stuff to the client?

Garrysmod seems to automatically load everything in the particles folder, so as far as I know, you don’t.

Again, haven’t slept in a long while so I may be asking something stupid, but how would I know how large a certain effect is?

Very nice guide, should help people who are new to particles.

Will give this a whirl when I get home, thanks. Might make for some good teleport effects for 1.2 of my STool.

Will read later after school, thanks for the tutorial, I’ve been interested in working with OB particles lately.

If by how large you mean in game size, you are able to spawn the effects in game while working on them simply by changing the map.

The little origin marker is also the same scale as it is in hammer (not really helpful for anyone who doesn’t use it a lot, but hey)

Question for you: I’m trying to make a fireworks-type particle, but there seems to be a problem. I can’t figure out how to make the particles fly out in every direction. There is a velocity random, but that’s just a multiplier for the length of the current velocity it seems. How exactly do I make the particles fly out at random (or at least in a sphere)?

But thank you for posting this, it’s very helpful.

Yes, there are random velocity initializers, but they form squares and other annoying nonsense.

What you can use instead is the position within sphere initializer.
Among its other functions, it has two special ones for random speed: speed_min and speed_max
You can use these to get random velocity in a spherical shape, or if you set them both at the same velocity, you can get an expanding sphere that is ‘hollow’.

If you use a continuous emitter, it will expand in a nautilus shell shaped movement (it doesn’t make sense until you actually see it.) to fix this, set the value speed_random_exponent to 0.1

thanks a lot, i was wondering how to get a cool smoke particle efect. the only thing that’s very hard (at least for me) is the Lua part but, i’ll figure it out.

Thank You so much for this.

Thanks! That helped a lot.

A few other things: how do you define control points in the editor? I see the control points tab, but it seems to only let me define #0.

And, I’m trying to make some fancy ring fireworks:

Basically, I just used position in sphere random’s directional bias to make rings. However, when I pass any angle to the ParticleEffect function it never changes angles. It just stays perfectly aligned with the axes. How can I change this?

make blood impact!!!

how can i let particles bounce from the ground if they have gravity?