• Particles Thread: All you need to know
    40 replies, posted
[B][highlight]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?[/highlight] What is a particle effect?[/B] 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. [B]How do I make one?[/B] 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. [B]How can I use them in lua?[/B] 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. [B]Control Points[/B] 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. [B]Limitations![/B] 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 :)
I actually needed this for something I'm working on :) 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.
[QUOTE=Skapocalypse;19779437]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?[/QUOTE] 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.
[QUOTE=Empty_Shadow;19793572]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.[/QUOTE] 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: [IMG]http://i182.photobucket.com/albums/x305/Entoros/ta_urbania_b60000.jpg[/IMG] 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?
Is there a way I can make particles move towards the control point? I tried the force thing, but it doesn't seem to have any effect. I made particles spawn in a 16 unit radius from the control point, but I can't seem to get them to move to the control point when they spawn.
[QUOTE=Entoros;19801755]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.[/quote] You need to have some particle function that's actually making use of a second control point. If the point ain't getting read anywhere, it won't let you define it - what would be the point? [QUOTE=Entoros;19801755]And, I'm trying to make some fancy ring fireworks: [IMG_THUMB]http://i182.photobucket.com/albums/x305/Entoros/ta_urbania_b60000.jpg[/IMG_THUMB] 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?[/QUOTE] Try changing the "bias in local system" property of the Position Within Sphere to 1. [QUOTE=Quanno;19804405]how can i let particles bounce from the ground if they have gravity?[/QUOTE] Use the "Collision via traces" Constraint. The only thing you need to change is the "amount of bounce" property, which should be somewhere between 0 and 1 (experiment with it), and possibly the "brush only" property, which should usually be 1 for efficiency reasons.
Question: How are particles made for Ep1 engine ? :/
@entoros If mahalis' idea doesn't work, you'll need a workaround: I'd say you'll have to do it differently. My thought right now is to create a small entity at the centre of the effect, and rather than use the particle angle stuff, use particleattach, and rotate the entity. This won't actually rotate it yet, you'll need to add some stuff. In Operators, you'll need to add 2 new operators, movement basic (no need to do anything special to it yet) and movement lock to control point. In movement lock to control point, leave control_point_number at 0, and set lock rotation to 1. It should now rotate with your entity. @Quanno, do what mahalis said @thomas In position within sphere, set the max and min speed to 16, then set the distance randoms to both -16. @mahalis stop stealing my thread :P @cNova Ep1 engine doesn't have OB particles. Take a guess why.
sweet, now i can make some good effects for my dimensional rifts :D
How might I place a particle in a map? I'm makeing it so when you shoot a control panel it sparks
[url]http://developer.valvesoftware.com/wiki/Info_particle_system[/url]
sweet thanks I'll give that a look
Updates: When you're using -tools, VGUI on other servers seems to stop accepting mouseclicks for unknown reasons. -tools also tends to make your game a little less stable, so remember to disable it when you aren't particling.
3 years later i entered -tools into the launch options and gmod hasnt changed, did an update change something?
Sorry, you need to Log In to post a reply to this thread.