Particles Tutorial: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Add first A1 → A3 example conversion: Burning Vehicle Fire Look-Alike) |
Lou Montana (talk | contribs) (→Full examples: Add Fire example) |
||
Line 88: | Line 88: | ||
{{Informative | The following examples are for {{arma2}} and later titles. For {{arma}} examples, see [[ParticleTemplates]].}} | {{Informative | The following examples are for {{arma2}} and later titles. For {{arma}} examples, see [[ParticleTemplates]].}} | ||
=== Burning Vehicle Fire Look-Alike === | === Burning Vehicle Fire Look-Alike === | ||
[[Image:PE_BurningVehicleLookAlike.jpg|thumb|left|100px|Burning vehicle fire look-alike]] | |||
[[private]] _posATL = [[player]] [[modelToWorld]] [0,10,0]; | [[private]] _posATL = [[player]] [[modelToWorld]] [0,10,0]; | ||
{{cc|Fire}} | {{cc|Fire}} | ||
[[private]] _ps0 = "#particlesource" [[createVehicleLocal]] _posATL; | [[private]] _ps0 = "#particlesource" [[createVehicleLocal]] _posATL; | ||
Line 100: | Line 99: | ||
0, 1, [0, 0, 0.25], [0, 0, 0.5], 1, 1, 0.9, 0.3, [1.5], | 0, 1, [0, 0, 0.25], [0, 0, 0.5], 1, 1, 0.9, 0.3, [1.5], | ||
[[1,1,1, 0.0], [1,1,1, 0.3], [1,1,1, 0.0]], | [[1,1,1, 0.0], [1,1,1, 0.3], [1,1,1, 0.0]], | ||
[0.75], 0, 0, "", "", _ps0, rad -45]; | [0.75], 0, 0, "", "", _ps0, rad -45]; | ||
_ps0 [[setParticleRandom]] [0.2, [1, 1, 0], [0.5, 0.5, 0], 0, 0.5, [0, 0, 0, 0], 0, 0]; | _ps0 [[setParticleRandom]] [0.2, [1, 1, 0], [0.5, 0.5, 0], 0, 0.5, [0, 0, 0, 0], 0, 0]; | ||
_ps0 [[setDropInterval]] 0.03; | _ps0 [[setDropInterval]] 0.03; | ||
Line 124: | Line 123: | ||
_ps2 [[setDropInterval]] 0.25; | _ps2 [[setDropInterval]] 0.25; | ||
=== Fire === | |||
[[Image:PE_fire.jpg|thumb|left|100px|Fire]] | |||
[[private]] _posATL = [[player]] [[modelToWorld]] [0,10,0]; | |||
{{cc|Fire}} | |||
[[private]] _ps1 = "#particlesource" [[createVehicleLocal]] _posATL; | |||
_ps1 [[setParticleParams]] [ | |||
["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 10, 32], "", "Billboard", | |||
1, 1, [0, 0, 0], [0, 0, 0.5], 0, 1, 1, 3, [0.5,1.5], | |||
[[1,1,1,0.4], [1,1,1,0.2], [1,1,1,0]], | |||
[0.25,1], 1, 1, "", "", _ps1]; | |||
_ps1 [[[[setParticleRandom]]]] [0.2, [0.5, 0.5, 0.25], [0.125, 0.125, 0.125], 0.2, 0.2, [0, 0, 0, 0], 0, 0]; | |||
_ps1 setDropInterval 0.05; | |||
{{cc|Smoke}} | |||
[[private]] _ps2 = "#particlesource" [[createVehicleLocal]] _posATL; | |||
_ps2 [[setParticleParams]] [ | |||
["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 1, 1], "", "Billboard", | |||
1, 5, [0, 0, 1], [0, 0, 1.5], 0, 1, 1, 0.5, [1.75,2,3,4.5], // timerPeriod → size | |||
[[1,1,1,0], [1,1,1,0.5], [1,1,1,0.4], [1,1,1,0.2], [1,1,1,0]], | |||
[0.5,0.5], 0, 0, "", "", _ps2]; | |||
_ps2 [[setParticleRandom]] [0.5, [1, 1, 0.4], [0, 0, 0.5], 0, 0.125, [0, 0, 0, 0], rad 30, 0]; | |||
_ps2 [[setDropInterval]] 0.1; | |||
== See also == | == See also == |
Revision as of 02:11, 8 August 2020
Basics
A particle is a (to some extent, non-physical) 2D plane that always faces the camera, or (more rarely) a 3D model. It can be used to simulate ambient effects, such as dust, fire, water splash, wood splinters and even rock debris.
A particle source is a non-physical object that creates particles at a certain rate and position/velocity.
A particle (as well as a particle source) is local to the computer where the script has been called; one player could see smoke while another could see through without any issue.
How to
Create a particle source
private _particleSource = "#particlesource" createVehicleLocal getPosATL player;
3
_particleSource setParticleClass "ObjectDestructionFire1Smallx"; // defined in configFile >> "CfgCloudlets"
Set source parameters
// see ParticleArray for details on the array format _particleSource setParticleParams [ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 0, 8], "", "Billboard", 1, 3, // animationName, type, timerPeriod, lifeTime [0,1.5,0], // position relative to referenceObject [0,0,0], // velocity 0, 0.005, 0.003925, 0.1, [0.25, 0.75], // rotation, weight, volume, rubbing, size [[1,0,0,0.5], [0,1,0,1], [0,0,01,0.25]], // colors [1], // animationPhase 0, 0, // randomDirectionPeriod, randomDirectionIntensity "", "", // onTimer, beforeDestroy player, // referenceObject 0, false, // angle, bounces -1, [], // bounceOnSurface, emissiveColor [0,0,0] // vectorDir ];
Set source drop interval
_particleSource setDropInterval 0.0625;
Set source drop circle
_particleSource setParticleCircle [3, [0,1,0]];
Set source random values
_particleSource setParticleRandom [0, [0.1, 0.1, 0.1], [0, 0, 0.5], 0, 0.1, [0, 0, 0, 0], 0, 0];
3
_particleSource setParticleFire [0.1, 0.5, 2];
Delete source
deleteVehicle _particleSource; // as simple as that
Use the drop command
The drop command only drops one particle. If multiple ones are needed, a loop (for, while) must be used.
// see ParticleArray for details on the array format drop [ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 0, 8], "", "Billboard", 1, 3, // animationName, type, timerPeriod, lifeTime [0,1.5,0], // position relative to referenceObject [0,0,0], // velocity 0, 0.005, 0.003925, 0.1, [0.25, 0.75], // rotation, weight, volume, rubbing, size [[1,0,0,0.5], [0,1,0,1], [0,0,01,0.25]], // colors [1], // animationPhase 0, 0, // randomDirectionPeriod, randomDirectionIntensity "", "", // onTimer, beforeDestroy player // referenceObject ];
Full examples
Burning Vehicle Fire Look-Alike
private _posATL = player modelToWorld [0,10,0]; // Fire private _ps0 = "#particlesource" createVehicleLocal _posATL; _ps0 setParticleParams [ ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 10, 32], "", "Billboard", 0, 1, [0, 0, 0.25], [0, 0, 0.5], 1, 1, 0.9, 0.3, [1.5], [[1,1,1, 0.0], [1,1,1, 0.3], [1,1,1, 0.0]], [0.75], 0, 0, "", "", _ps0, rad -45]; _ps0 setParticleRandom [0.2, [1, 1, 0], [0.5, 0.5, 0], 0, 0.5, [0, 0, 0, 0], 0, 0]; _ps0 setDropInterval 0.03; // Smoke part 1 private _ps1 = "#particlesource" createVehicleLocal _posATL; _ps1 setParticleParams [ ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 1], "", "Billboard", 1, 10, [0, 0, 0.5], [0, 0, 2.9], 1, 1.275, 1, 0.066, [4, 5, 10, 10], [[0.3, 0.3, 0.3, 0.33], [0.4, 0.4, 0.4, 0.33], [0.2, 0.2, 0, 0]], [0, 1], 1, 0, "", "", _ps1]; _ps1 setParticleRandom [0, [0, 0, 0], [0.33, 0.33, 0], 0, 0.25, [0.05, 0.05, 0.05, 0.05], 0, 0]; _ps1 setDropInterval 0.5; // Smoke part 2 private _ps2 = "#particlesource" createVehicleLocal _posATL; _ps2 setParticleParams [ ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 9, 1], "", "Billboard", 1, 15, [0, 0, 0.5], [0, 0, 2.9], 1, 1.275, 1, 0.066, [4, 5, 10, 10], [[0.1, 0.1, 0.1, 0.75], [0.4, 0.4, 0.4, 0.5], [1, 1, 1, 0.2]], [0], 1, 0, "", "", _ps2]; _ps2 setParticleRandom [0, [0, 0, 0], [0.5, 0.5, 0], 0, 0.25, [0.05, 0.05, 0.05, 0.05], 0, 0]; _ps2 setDropInterval 0.25;
Fire
private _posATL = player modelToWorld [0,10,0]; // Fire private _ps1 = "#particlesource" createVehicleLocal _posATL; _ps1 setParticleParams [ ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 10, 32], "", "Billboard", 1, 1, [0, 0, 0], [0, 0, 0.5], 0, 1, 1, 3, [0.5,1.5], [[1,1,1,0.4], [1,1,1,0.2], [1,1,1,0]], [0.25,1], 1, 1, "", "", _ps1]; _ps1 [[setParticleRandom]] [0.2, [0.5, 0.5, 0.25], [0.125, 0.125, 0.125], 0.2, 0.2, [0, 0, 0, 0], 0, 0]; _ps1 setDropInterval 0.05; // Smoke private _ps2 = "#particlesource" createVehicleLocal _posATL; _ps2 setParticleParams [ ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 1, 1], "", "Billboard", 1, 5, [0, 0, 1], [0, 0, 1.5], 0, 1, 1, 0.5, [1.75,2,3,4.5], // timerPeriod → size [[1,1,1,0], [1,1,1,0.5], [1,1,1,0.4], [1,1,1,0.2], [1,1,1,0]], [0.5,0.5], 0, 0, "", "", _ps2]; _ps2 setParticleRandom [0.5, [1, 1, 0.4], [0, 0, 0.5], 0, 0.125, [0, 0, 0, 0], rad 30, 0]; _ps2 setDropInterval 0.1;
See also
- Category:Particle System
- ParticleArray - particle array format