|
|
what the hecks wrong here?
#138296
06/26/07 20:09
06/26/07 20:09
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
this is weird, useing code from one of the aum tuts which works ok in one project but not in another, i`m stumped. please please tell me were the heck is this wrong? the torp just goes straight through the dummy target. Code:
string redflare_pcx = "redflare.pcx";
sound torp_wav = <torp.wav>;
function move_torp1(); function remove_torp1();
function f_torp1 { vec_for_vertex (temp, player, 3088) ; ent_create (redflare_pcx, temp, move_torp1); snd_play (torp_wav, 50, 0); }
function move_torp1 { var bullet_speed; // this var will store the speed of the bullet var trace_coords; my.enable_entity = on; my.enable_block = on; my.enable_impact = on; my.polygon = on; my.visible = on; my.transparent = on; my.bright = on; my.passable = off; my.scale_x = 0.5;//scale it down to have it's size my.scale_y = my.scale_x;//same as scale x my.scale_z = my.scale_x;//same as scale x my.event = remove_torp1; // when it collides with something, its event function (remove_bullets) will run vec_set(my.pan, player.pan); bullet_speed.x = 40 * time; // adjust the speed of the bullet here bullet_speed.y = 0; // the bullet doesn't move sideways bullet_speed.z = 0; // then don't allow the gravity to have its ways with the bullet while (my != null) // this loop will run for as long as the bullet exists (it isn't "null") { // move the bullet ignoring the passable entities and store the result in distance_covered c_move (my, bullet_speed, nullvector, ignore_passable); wait (1); } }
function remove_torp1() // this function runs when the bullet collides with something { wait (1); my.passable = on; my.visible = off; sleep (2); ent_remove (my); }
this works ok in the tut i did, but now it won`t? here is the dummy function Code:
function f_ship { wait(1); my.scale_x = 3.0; my.scale_y = my.scale_x; my.scale_z = my.scale_x; my.enable_impact = on; my.enable_entity = on; my.polygon = on; my.enable_scan = on; my.enable_detect = on; my.passable = off; my.event = got_shot; }
function got_shot() { my.event = destroy_me; wait(1); }
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: what the hecks wrong here?
[Re: Xarthor]
#138298
06/27/07 16:10
06/27/07 16:10
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
if you mean like this the nit did`nt work, have i done it wrong? Code:
my.scale_x = 0.5, ;//scale it down to have it's size wait(1); c_updatehull(my,my.frame); wait(2); my.scale_y = my.scale_x;//same as scale x wait(1); c_updatehull(my,my.frame); wait(2); my.scale_z = my.scale_x;//same as scale x wait(1); c_updatehull(my,my.frame); wait(2);
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: what the hecks wrong here?
[Re: jigalypuff]
#138299
06/27/07 17:12
06/27/07 17:12
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
No I meant it this way: Code:
my.scale_x = bla my.scale_y = bla my.scale_z = bla wait(1); c_updatehull(my,my.frame); wait(2);
However it makes no difference. But: Did you also do this change to the bullet's function? EDIT: argh I guess I know whats wrong. You set the my.polygon flag for the torpedo to ON. Here it comes: NEVER ever use the polygon flag for dynamic (moving) entities. It may mess up your collision detection! EDIT: further more, your torpedo only adjusts its speed to the framerate once and not every frame. write: bullet_speed.z = 40; while(my!=null) { c_move(my, bullet_speed*time_step, nullvector, ignore_passable); wait(1); }
Last edited by Xarthor; 06/27/07 17:17.
|
|
|
Re: what the hecks wrong here?
[Re: Xarthor]
#138300
06/27/07 17:59
06/27/07 17:59
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
that *time_step gives a crash in the c_move instruction, when it`s not there the torp fires but passes through the target if it`s in i get the crash, what i don`t understand is why the function works in one project but not this one, i copied and pasted the code, should it not work?
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: what the hecks wrong here?
[Re: Xarthor]
#138302
06/27/07 19:25
06/27/07 19:25
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
ya i removed the polygon flag, still not working, i just tried turning my.passable = off in the remove_torp1 function, the torp gets stuck to the ship, is it possible that for some reason the my.passable = on in that function is activateing to early?
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
Re: what the hecks wrong here?
[Re: Xarthor]
#138304
06/27/07 20:21
06/27/07 20:21
|
Joined: Nov 2005
Posts: 1,007
jigalypuff
OP
Serious User
|
OP
Serious User
Joined: Nov 2005
Posts: 1,007
|
i`m getting empty pointer in move torp, here is what i did, and thanks for all this help Code:
function move_torp1 { var bullet_speed; // this var will store the speed of the bullet var trace_coords; my.skill1 = 1; my.enable_entity = on; my.enable_block = on; my.enable_impact = on; my.visible = on; my.transparent = on; my.bright = on; my.passable = off; my.scale_x = 0.5;//scale it down to have it's size my.scale_y = my.scale_x;//same as scale x my.scale_z = my.scale_x;//same as scale x my.event = remove_torp1; // when it collides with something, its event function (remove_bullets) will run vec_set(my.pan, player.pan); bullet_speed.x = 40 * time_step; // adjust the speed of the bullet here bullet_speed.y = 0; // the bullet doesn't move sideways bullet_speed.z = 0; // then don't allow the gravity to have its ways with the bullet while (my.skill1); // this loop will run for as long as the bullet exists (it isn't "null") { // move the bullet ignoring the passable entities and store the result in distance_covered c_move (my, bullet_speed, nullvector, ignore_passable); wait (1); ent_remove(me); } }
function remove_torp1() // this function runs when the bullet collides with something { my.skill1 = 0;
}
Why does everyone like dolphins?
Never trust a species which smiles all the time!
|
|
|
|