6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Particle
[Re: Thomas]
#229410
09/27/08 11:05
09/27/08 11:05
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
To create a particle effect right in front of an entity (in this case the "player" entity) you first need to find the position which is right in front of it. This can be done with the following snippet:
var particle_dist[3] = 50,0,0; // effect is 50 quants in front of the player
function particle_StartEffect()
{
var effect_pos[3];
vec_set(effect_pos, particle_dist);
vec_rotate(effect_pos, player.pan);
vec_add(effect_pos, player.x);
}
Now the vector "effect_pos" contains the position in front of the player entity based upon the particle_dist vector and the rotation of the player entity. Next thing to do is to implement the toggle behaviour, this can be achieved with a "control" variable:
var particle_status = 0;
var particle_dist[3] = 50,0,0; // effect is 50 quants in front of the player
function particle_ToggleEffect()
{
var effect_pos[3];
particle_status = !particle_status; //inverting the current status, thus 0 gets 1 and 1 gets 0
while(particle_status)
{
vec_set(effect_pos, particle_dist);
vec_rotate(effect_pos, player.pan);
vec_add(effect_pos, player.x);
effect(yourEffect,5,effect_pos,nullvector);
wait(1);
}
}
on_p = particle_ToggleEffect;
That should do the job. Attention: I wrote this script from the top of my head, thus I'm not 100% sure that each instruction is correct, but I'll check if you have problems with it.
|
|
|
|