Jump to content
cervantes

perfect rotation from particles emiter by script

Recommended Posts

hi here i fixed today one issue with my last particles emiter script and want share that with this amazing community 😉

 

this script have for but to work exatly with same direction and position params  from emmiter in config bin or cpp.

generaly we attach a particles emiters with attachto but an attached emiter can't be turn corectly with others objects 🙂

 

a emiters define in config use generaly from position and particles directions this params and memories points:

 

 

        moveVelocity[]=
        {
            "2*directionX",
            "2*directionY",
            "2*directionZ"
        };

        position[]=
        {
            "positionX + 0.12 * directionLocalX",
            "positionY + 0.12 * directionLocalY",
            "positionZ + 0.12 * directionLocalZ"
        };

 

of course is not eazy to write same params with script especialy for a setParticleParams and setParticleRandom.

but that is possible :)

 

i use in this exemple a machineguncloud FX params for simulating a overheat from mg barrel, but i disable a wind affect and invert a direction for my smoke fly on back and not on front

and i apply a velocty of particles on the angle of my weapon direction 😉

 

Spoiler

_mg=_this select 0;


_pArray = [];


for "_i" from 1 to 1 do
{
_mem_pos  = _mg selectionposition ["usti hlavne", "Memory"];
_x = _mem_pos select 0;
_y = _mem_pos select 1;
_Z = _mem_pos select 2;

_pos = _mg modelToWorld [_x,_y,_z];
_vdir = _mg weaponDirection currentWeapon _mg;
_angle = (_vdir select 0) atan2 (_vdir select 1)-180;
//cuttext[format["Captive: %1",_angle],"plain down",0.6];
_smoke = "#particlesource" createVehicleLocal _pos;
_smoke setParticleParams [["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 12, 8,1],
"", 
"Billboard", 
1, 
0.80000001,
[_x,_y,_z],// memorie point position
[2*sin(_angle),2*cos(_angle),random 0.2 - random 0.2],  //moveVelocity
1, 0.050000001,0.039999999, 0, 
[0.30000001,0.69999999,1,1.2,1.4,1.6,1.8], //size
[[0.89999998,0.89999998,0.89999998,0.079999998], [0.89999998,0.89999998,0.89999998,0.035999998], [0.89999998,0.89999998,0.89999998,0.012], [0.89999998,0.89999998,0.89999998,0.001]], 
[1.2], 
0.1, 
0.050000001, 
"", 
"", 
_mg,
0.5,
false,
-1,
[]

];
_smoke setParticleRandom [1, [0, 0, 0], [0, -1, 0], 20, 0, [0, 0, 0, 0], 0, 0, 0.5];
_smoke setDropInterval 0.0099999998;
_pArray pushBack _smoke;

    };

    _pArray spawn 
    {
        _pArray = _this;
        sleep 2;
        { deleteVehicle _x } foreach _pArray;
    };

 

_mem_pos  = _mg selectionposition ["usti hlavne", "Memory"];

normaly works but work only on editor not in multiplayer alone, for fix that i define again a position on memory point with modeltoworld 😉

_x = _mem_pos select 0;
_y = _mem_pos select 1;
_Z = _mem_pos select 2;

_pos = _mg modelToWorld [_x,_y,_z];

 

the angle with weapon direction for apply a particles velocity directions

 

_vdir = _mg weaponDirection currentWeapon _mg;
_angle = (_vdir select 0) atan2 (_vdir select 1)-180;

 

or _angle = (_vdir select 0) atan2 (_vdir select 1)

for no invert direction.

 

[2*sin(_angle),2*cos(_angle),random 0.2 - random 0.2], observing that math formula is same to "2*directionX","2*directionY" 😉

 

now a particle emiter turn perfectly with a memorie point and apply a velocity of particles on realy wanted direction and position.

 

friendly Cervantes.

  • Thanks 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×