Particle rotating around the player

Posted By: Vyse220

Particle rotating around the player - 08/24/08 21:48

I'm trying to create a videogame, i'm asking for a code of a particle fuction that must be like a comet rotating around the player.
I'm still a newbie, if someone can show me the code or give me a tutorial i will be glad.
Thx and sorry for my bad english
Posted By: Impaler

Re: Particle rotating around the player - 08/25/08 11:17

For a comet rotating around the player, I'd try something like this:


//this function controls the rotation of the comet
function comet_turn()
{
var radius = 100;
var angle = 0;
var speed = 5;
while(my)
{
angle += speed * time_step;//rotate the angle
vec_set(my.x, your.x);
my.x += radius * cos(angle);//figure out x and y position
my.y += radius * sin(angle);
effect(comet_trail, 1, my.x, nullvector);//particle effect
wait(1);
}
}

// create a comet object from the player action: just insert this at the start of your player's action

ent_create("asteroid.mdl", my.x, comet_turn);


hope this works! you'll have to substitute your own files for the comet model and your own particle effect for the rotating comet to leave a trail.
© 2024 lite-C Forums