|
|
Re: problem with target...
[Re: tompo]
#121272
04/20/07 01:18
04/20/07 01:18
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
@Tompo: Wrong dude. The crosshair is always at the center of the screen. You simply need to use the camera's position and angles. The code I posted (very similar to ManSlayers) should work just fine.
I'd like to see the code for the bullet, and it's generation (ent_create())...
xXxGuitar511 - Programmer
|
|
|
Re: problem with target...
[Re: xXxGuitar511]
#121273
04/20/07 08:39
04/20/07 08:39
|
Joined: Mar 2007
Posts: 776 Poor village - Poland ;)
tompo
User
|
User
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
|
yes I know about crosshair...but he want trace from camera to far pont in the middle of the screen. So I told that he may use vec_for_screen function with temp.z to put target away from camera. with temp.x and temp.y in screen_size /2 (in the middle of the screen) Is that wrong? And then trace from that far point, to player (or camera) to check if hit something and put there a target. Then create bullet hole in target position, or create a bullet in gun position and move it byf.e. vel_x function with vec_diff from player to target. I've jused something like this in 3rd person space shooter & everything was ok?!
Last edited by tompo; 04/20/07 09:24.
Never say never.
|
|
|
Re: problem with target...
[Re: tompo]
#121274
04/20/07 13:11
04/20/07 13:11
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
hmm...manslayer: what I did was moving the crosshair to the place where the bullet would hit if you'd shoot right at this moment... I guess what you want is different though.
you trace 50000 quants ahead of the model and then do vec_for_screen() and get the screen pos of the target vector, and place the crosshair there...?
just an idea.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: problem with target...
[Re: Germanunkol]
#121275
04/20/07 14:20
04/20/07 14:20
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
ok, i'll post the code that was used with 6.3: Code:
function bullet_event() { if (event_type == event_block) { c_trace(my.pos, your.pos, SCAN_TEXTURE); if (tex_flag1) { ent_create("bulhole.tga",my.x,bullet_hole); spark01_action(); } if (tex_flag2) { ent_create ("bulhole.tga", my.x, bullet_hole); } if (tex_flag3) { ent_create ("bulhole.tga", my.x, bullet_hole); } my.bullethit = on; ent_create ("cool_explo+9.tga", my.x, spark_spr_efx); } if (event_type == event_entity) { you.skill73 = 0; you.skill72 *= 5; if (you.blocking == 0) { you.health -= 5; } spark01_action(); wait(1); my.bullethit = on; //ent_create ("cool_explo+9.tga", my.x, spark_spr_efx); ent_create ("dust+8.tga", my.x, dust_spr_efx); sleep(10); you.skill72 /= 5; } }
action bullet_move { //ent_create ("block.mdl", my.x, scan_block_act); make_passable(); my.skill40 = 1; my.scale_x = 0.5; my.scale_y = my.scale_x; my.scale_z = my.scale_x; my.bright = on; max_dist = 20000; if (you.skill70 == 0) { turn_towards_target(); } else { my.pan = you.pan; my.tilt = you.tilt; my.roll = you.roll; } my.enable_block = ON; my.enable_entity = ON; my.event = bullet_event; while (my.skill20 < max_dist && my.bullethit == off) { move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ignore_sprites; my.skill20+= ent_move(vector(1000 *time,0,0),nullvector); wait(1); } ent_remove (me); }
function turn_towards_target() { vec_set(temp,vector(9999999,0,0)); //Set temp to a 2000 quant long line vec_rotate(temp,camera.pan); //Rotate line by camera vec_add(temp,camera.x); //Align temp with the camera trace_mode = ignore_me + ignore_you + ignore_passable + ignore_sprites; //Or whatever you want result = trace(camera.x,temp.x); //Trace between them, may want to use c_trace if(result == 0) //Nothing was traced { vec_sub(temp,my.x); //Take my pos out of the trace-to location vec_to_angle(my.pan,temp); //Point towards it } else { vec_set(temp,target.x); //Get the traced location vec_sub(temp,my.x); //Take my pos out of the equation vec_to_angle(my.pan,temp); //Point towards it } }
function spawn_bullet_chaingun() { var bulletCreatePos[3]; bulletCreatePos[0] = 85; bulletCreatePos[1] = -42; bulletCreatePos[2] = -5; vec_rotate(bulletCreatePos, my.pan); vec_add(bulletCreatePos, my.x); ent_create("bullet.mdl", bulletCreatePos, bullet_move); ent_create("m_flash.mdl", bulletCreatePos, muzzle_cgun2); }
this is most of the relevant (and irrelavent) bullet code, the way a bullet is created is in the player's fire function, i call spawn_bullet_chaingun(); after setting the firetime, etc. please use it for reference, and see how it used to work, if any of you have played PreVa's beta demo, you'll know that this code worked perfectly fine then, but now it's not working at all, it gives a completely different result, and it's caused from the turn_towards_target function...
- aka Manslayer101
|
|
|
Re: problem with target...
[Re: mpdeveloper_B]
#121276
04/23/07 05:11
04/23/07 05:11
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
this problem is still existent, i'm still having problems converting that code to a6.5 code, so it will work
- aka Manslayer101
|
|
|
Re: problem with target...
[Re: mpdeveloper_B]
#121277
04/23/07 17:05
04/23/07 17:05
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
problem fixed, one too many nines
- aka Manslayer101
|
|
|
Re: problem with target...
[Re: xXxGuitar511]
#121279
04/25/07 17:08
04/25/07 17:08
|
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B
OP
Expert
|
OP
Expert
Joined: Feb 2006
Posts: 2,185
|
i don't understand why i was allowed to do it with the earlier version though....ah well...
thank you all for helping, you're going in the credits...the fact that one number killed my firing code sucks but hey.....
Last edited by Manslayer101; 04/25/07 17:11.
- aka Manslayer101
|
|
|
|