0 registered members (),
16,643
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
spray direction
#199709
04/01/08 06:38
04/01/08 06:38
|
Joined: Apr 2007
Posts: 83
prog
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 83
|
Hello, I want the smoke to come out in the direction of the player,i.e, it should look like as if the player is spraying.
This is the code i am using and the player is PlBiped(A6 template).
BMAP px_tga = "smog_02.tga"; function fade_p() { my.alpha -= 10 * time_step; if (my.alpha < 0) {my.lifespan = 0;} }
function effect_x() { my.alpha = 30 + random(65); my.flare = on; my.bmap = px_tga; my.size = 12; my.bright = on; my.move = on; my.function = fade_p; }
function create_px() { var temp_pos; var temp_var; while (1) { temp_pos.x += 20 * cos(plBiped01_entity.x); // 20 = particle radius temp_pos.y += 20 * sin(plBiped01_entity.x); // use the same value here effect(effect_x, 1, temp_pos.x, nullvector); wait (1); } } on_m = create_px;
Last edited by prog; 04/01/08 06:39.
|
|
|
Re: spray direction
[Re: prog]
#200056
04/02/08 12:25
04/02/08 12:25
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
instead of:
while (1) { temp_pos.x += 20 * cos(plBiped01_entity.x); // 20 = particle radius temp_pos.y += 20 * sin(plBiped01_entity.x); // use the same value here effect(effect_x, 1, temp_pos.x, nullvector); wait (1); }
try:
while (1) { vec_set(temp,vector(20,0,0)); vec_rotate(temp,(plBiped01_entity.pan); vec_add(temp,(plBiped01_entity.x); effect(effect_x, 1, temp, nullvector); wait (1); }
also, temp_pos is not a vector, the way you're defining it, but you're acting like it is.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: spray direction
[Re: Xarthor]
#201801
04/11/08 08:54
04/11/08 08:54
|
Joined: Apr 2007
Posts: 83
prog
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2007
Posts: 83
|
Ya, the smoke should spray only once, not through out the game. The game has 4 levels and only in 2nd level smoke has to be sprayed and only once(ie., when 'M' is presses and should stop after we release 'M') after that the player has to perform other actions(ie., has to go and touch the skycar...). But using the below code.., the smoke is visible throught out the game(ie., in all the levels after we execute this function). But, it has to spray when we click on_M and stop spraying after we release the button.
BMAP px_tga = "smog_02.tga";
function fade_p()
{
my.alpha -= 10 * time_step;
if (my.alpha < 0) {my.lifespan = 0;}
}
function effect_x()
{
my.alpha = 30 + random(65);
my.flare = on;
my.bmap = px_tga;
my.size = 12;
my.bright = on;
my.move = on;
my.function = fade_p;
}
function create_px()
{
while (1)
{
vec_set(temp,vector(20,0,0));
vec_rotate(temp,(plBiped01_entity.pan);
vec_add(temp,(plBiped01_entity.x);
effect(effect_x, 1, temp, nullvector);
wait (1);
}
}
on_m = create_px;
|
|
|
Re: spray direction
[Re: prog]
#201810
04/11/08 10:24
04/11/08 10:24
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
I don't know whether this is reasonable within the whole of your game, but it should do the task, although not tested.
function create_px() { while (1) { add here:if(key_m) add here:{ vec_set(temp,vector(20,0,0)); vec_rotate(temp,(plBiped01_entity.pan); vec_add(temp,(plBiped01_entity.x); effect(effect_x, 1, temp, nullvector); add here:} wait (1); } } remove this line:on_m = create_px;
----------- BTW: How can I format this as code?
|
|
|
|