|
1 registered members (alibaba),
3,864
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Flamethrower
[Re: Kartoffel]
#363774
03/14/11 18:03
03/14/11 18:03
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Ok, I'll try with box thing  About vec_rotate, yes I use velocity vector for particles. I do it like this: VECTOR temp_pos; temp_pos.x = 20 * time_step; temp_pos.y = 0; temp_pos.z = 0; vec_set(p.vel_x,temp_pos.x); vec_rotate(temp_pos.x,camera.pan);
|
|
|
Re: Flamethrower
[Re: 3run]
#363809
03/14/11 20:01
03/14/11 20:01
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Sorry for the late answer  Well i think this should work:
VECTOR temp_pos;
VECTOR particle_vel;
vec_set(temp_pos,nullvector); // this needs not that much lines :P
temp_pos.x = 20 * time_step; // " " " " " " " "
vec_set(particle_vel,temp_pos);
vec_rotate(particle_vel,flamethrower.pan) //flamethrower= pointer to the flamethrower entity
//(i think the flamethrower always has the same
//angle, the particles fly)
vec_set(p.vel_x,particle_vel);
vec_rotate(temp_pos.x,camera.pan);
another thing: you should run the code above for every particle ONCE otherwise the particle wil change their direction if you turn the flamethrower [EDIT] you use: vec_set(p.vel_x...); this should work, but try it without setting the vars as vector. what i mean is this: p.vel_x = your_velocity_vector.x; p.vel_y = your_velocity_vector.y; p.vel_z = your_velocity_vector.z;
Last edited by Kartoffel; 03/14/11 20:06.
POTATO-MAN saves the day! - Random
|
|
|
Re: Flamethrower
[Re: Kartoffel]
#363812
03/14/11 20:19
03/14/11 20:19
|
Joined: Jun 2006
Posts: 379 Flevoland, 5 meters under wate...
Roel
Senior Member
|
Senior Member
Joined: Jun 2006
Posts: 379
Flevoland, 5 meters under wate...
|
I see the problem:
vec_set(p.vel_x,temp_pos.x);
vec_rotate(temp_pos.x,camera.pan);
first you set the velocity to the temo vector. and then you rotate the temp vector. the temp vector now has the right direction, but you should copy it's contents to the vel_x vector!  just swap these lines, and I think life gets some easier.
|
|
|
Re: Flamethrower
[Re: Roel]
#363813
03/14/11 20:24
03/14/11 20:24
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I see the problem:
vec_set(p.vel_x,temp_pos.x);
vec_rotate(temp_pos.x,camera.pan);
first you set the velocity to the temo <-(i found a mistake! xD) vector. and then you rotate the temp vector. the temp vector now has the right direction, but you should copy it's contents to the vel_x vector!  just swap these lines, and I think life gets some easier. I saw this, too. but i thought it should be like this (it should be obvious that it wont work). so in my posted code i created a new vector.
POTATO-MAN saves the day! - Random
|
|
|
Re: Flamethrower
[Re: Kartoffel]
#363844
03/14/11 23:14
03/14/11 23:14
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
Get rid of time_step -- particle movement through the vel_x vector automatically uses time_step, so it'll make things worse, even after you fix things as Roel and others pointed out.
Jibb
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
Re: Flamethrower
[Re: JibbSmart]
#364002
03/15/11 22:06
03/15/11 22:06
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Thank you all guys, but something is going wrong, please check it out:
function fade_flames(PARTICLE* p)
{
p.alpha += 1.5 * time_step;
p.size += 1 * time_step;
if(p.alpha < 0){p.lifespan = 0;}
}
function flames(PARTICLE* p)
{
VECTOR vTemp;
vTemp.x = 50;
vTemp.y = 0;
vTemp.z = 0;
vec_rotate(vTemp.x,camera.pan);
vec_add(p.vel_x,vTemp.x); // tried with vec_set and separately too
p.bmap = flame_tga;
p.size = 1 + random(2);
p.alpha = 100;
set(p,BRIGHT|MOVE|TRANSLUCENT);
p.event = fade_flames;
}
It looks weird, as if alpha was decresing with high speed, I tried without event, same result. I create particles in function which I call in while loop, and I use "wait(-0.5);" for creating speed...
|
|
|
Re: Flamethrower
[Re: 3run]
#364494
03/18/11 16:54
03/18/11 16:54
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Forgive me for all stupid questions I've asked here, solution was quit easy. You can download flamethrower demo here: Flamethrower thread Feel free to use it!
|
|
|
|