ParticleArray

From Bohemia Interactive Community
Revision as of 10:48, 3 December 2013 by DarkDruid (talk | contribs) (→‎Example)
Jump to navigation Jump to search

Introduction

Syntax

Format: [ShapeName, AnimationName, Type, TimerPeriod, LifeTime, Position, MoveVelocity, RotationVelocity, Weight, Volume, Rubbing, Size, Color, AnimationPhase, RandomDirectionPeriod, RandomDirectionIntensity, OnTimer, BeforeDestroy, Object, Angle, OnSurface, BounceOnSurface]

Note: OnSurface and BounceOnSurface parameters are supported since Arma3 v. 0.74.


Example

Create thunderbolt on logic named logic1

_pos = [ position logic1 select 0,position logic1 select 1,10 ];
drop ["blesk1","","Billboard",0.01,0.2,_pos,[0,0,0],0,1,1,0,[20 + random 20],[[1,1,1,1],[1,1,1,0.7]],[1,0],0,0,"","",""];

For several examples for the kind of effects that can be accomplished via particles, see ParticleTemplates.

// SCRIPT FOR GENERATING FLYES AROUND MASS GRAVE

// FIXED PARAMS
_source = "#particlesource" createVehicleLocal getPos (_this select 0);
_source setParticleParams
/*Sprite*/		[["\ca\characters2\OTHER\FLY.p3d",1,0,1,0],"",// File,Ntieth,Index,Count,Loop(Bool)
/*Type*/			"spaceObject",
/*TimmerPer*/		1,
/*Lifetime*/		4,
/*Position*/		[0,0,0],
/*MoveVelocity*/	[0,0,0.5],
/*Simulation*/		1,1.30,1,0,//rotationVel,weight,volume,rubbing
/*Scale*/		[0.03,0.03,0.03,0],
/*Color*/		[[1,1,1,1],[1,1,1,1]],
/*AnimSpeed*/		[1.5,0.5],
/*randDirPeriod*/	0.01,
/*randDirIntesity*/	0.08,
/*onTimerScript*/	"",
/*DestroyScript*/	"",
/*Follow*/		_this
/*Angle*/              0,   /*Arma 3 version 1.00 and higher*/
/*onSurface*/          true,   /*Arma 3 version 1.06 and higher*/
/*bounceOnSurface*/    0.5,   /*Arma 3 version 1.06 and higher*/
/*emissiveColor*/      [[0,0,0,0]]];   /*Arma 3 version 1.08 and higher*/

// RANDOM / TOLERANCE PARAMS
_source setParticleRandom
/*LifeTime*/		[2,
/*Position*/		[2,2,0.25],
/*MoveVelocity*/	[0,0,0],
/*rotationVel*/		1,
/*Scale*/		0.02,
/*Color*/		[0,0,0,0.1],
/*randDirPeriod*/	0.01,
/*randDirIntesity*/	0.03,
/*Angle*/		10];

_source setDropInterval 0.003;
a = createSoundSource["Sound_Flies",getPos (_this select 0),[],0];

Parameters

Global parameters

ArmA particle texture

ShapeName - Name of the shape associated with the particle (see ParticleShape list).

In ArmA, the ShapeName is defined as an array. This should be the particle shape name, followed by three integers.
Example: ["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 5, 0]
1. Anim Divisor (1 for a 1x1, 8 for a 8x8, etc)
2. Anim Starting Row
3. Number of Frames to Play (speed controlled by animation phase below)
In this shot of "\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", note the following:
The image used for this particle effect is 8X8 effect frames. This means you need to use 8 as your Anim Divisor. Overwise, the game will either draw too much of the image used, or too little. This is highly visible in most situations.
The Anim Starting Row picks the coresponding superimposed number in the image above. 0 picks the first smoke effect, 1 picks the second smoke effect, 2 picks the first fire effect, etc.
The setting for the Number of Number of Frames to Play should, in most cases, be the number of effects available to the animation. If you go over this (for example, selecting 9 in this 8X8 tile), it will start playing the animation frames of the next effect down. If there is nothing below to grab, it will draw a blank for that frame. If 1 is used, it will only play the first frame of the selected row.
If you want to find out of how many rows a datasource consists use ["...", 1, 0, 1] to see the full picture as a particle.
Arma2 particle texture

In ArmA 2 (and OA), the method for determining how many frames to play has changed.

Example 1:

["\Ca\Data\ParticleEffects\Universal\Universal", 16, 10, 32, 1]
1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)
2. Anim Starting Row (starting a 0)
3. Number of Frames to play (Starting with 1 and not 0)
4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
Example 1 above (a fire burning) will start the animation in row 10, will play from frames 1 to 32, and will loop.


Also in ArmA 2 and OA, To achieve a single frame of animation that is not the first column of a row, use the third numerical value as a column selection instead of indicating how many frames to play.

Example 2:

["\Ca\Data\ParticleEffects\Universal\Universal", 16, 12, 9, 0]
1. Anim Divisor (for the new Universal particle model it is 16 since the texture file is 16x16)
2. Anim Starting Row (starting at 0)
3. Column Selection (Starting with 1 and not 0)
4. Animation Loop (0 = no loop, 1 = loop (default if left blank is 1))
Additional Step: You must also set the AnimationPhase value (described in render parameters) to a large number (such as 1000) if you only want to play a single frame. The reason for this is that the game engine does not only play a single frame, it actually begins at the first frame in the row and cycles to the desired frame. If a small AnimationPhase number is used then you can actualy see the animation cycle through the all the frames (1-9). A large number makes this imperceptible and only the desired frame appears to be displayed.
Example 2 above (exploding rock dust) will start the animation in row 12, will only play frame 9, and will not loop.


AnimationName - Has to be a String, but it is obsolete.

Type - Type of particle (either "Billboard" or "SpaceObject").

TimerPeriod - The period of calling the "OnTimer" event (in sec).

LifeTime - Life time of the particle (in sec).

Physical parameters:

Position -' Either 3D coordinate (x, y, z) or name of the selection - in this case the Object property must be set.

MoveVelocity - 3D vector (x, y, z) which describes the velocity vector of the particle direction and speed in m/s.

RotationVelocity - Float number which determines number of rotations in one second.

Weight - Weight of the particle (kg).

Volume - Volume of the particle (m^3).

Rubbing - Float number without dimension which determines the impact of the density of the environment on this particle. 0 - no impact (vacuum).

Angle - Float number which determines starting angle of the particle.

OnSurface - Boolean. Placing of particle on (water) surface on start of it's existence, default value is true, works only if circleRadius > 0. Circle radius is defined by command setParticleCircle. Works since Arma 3 v. 0.74.

BounceOnSurface - Coef of speed's loosing in collision with ground, 0-1 for collisions, -1 disable collision. Default value -1. Should be used soberly, it has significant impact on performance. Works since Arma 3 v. 0.74.

Render parameters

Note: All these values are set as arrays to show their development in time.

If you set the array [1, 2] as a size, then at the beginning the size of the particle will be 1 and at the end of the life time of the particle it's size will be 2.

The rest of the values during the life time will be linearly interpolated.


Size - Size of the particle in time to render (m).

Color - Colour of the particle in time to render (RGBA).

AnimationPhase - Phase of the animation in time. In other words, the play speed of the selected frames for the Number of Frames to Play above. The higher the number, the faster it plays through the animation frames. Note that if the Number of Frames to Play above is set to 1, this will have no visible effect.

Random parameters:

RandomDirectionPeriod - Period of change of the velocity vector (s).

RandomDirectionIntensity - Each MoveVelocity component will be changed with random value from interval <0, RandomDirectionIntensity>.

OnTimer - Name of the script to run every period determined by TimerPeriod property.

Position of the particle is stored in "this" variable.

BeforeDestroy - Name of the script to run right before destroying the particle.

Position of the particle is stored in "this" variable.

Object - Object to bind this particle to.

Tutorials

Vektorboson's Drop Tutorial

See Also

setParticleCircle, setParticleParams, setParticleRandom, ParticleTemplates