|
My bullets don't go to the middle of the crosshair.Look ->
#303295
12/27/09 22:24
12/27/09 22:24
|
Joined: Dec 2009
Posts: 74 Romania,Bucharest
Ted22
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 74
Romania,Bucharest
|
My bullets don't go to the middle of the crosshair.Them aren't going to the middle of my crosshair.pcx,them are going to where the crosshair.pcx begins(on x,y)...Please help!Here is a part of the code:
.............................
mouse_mode=1; mouse_map = crosshair_pcx; wait (2); while (1) { mouse_pos.x = 400; mouse_pos.y = 300; camera.pan -= mouse_force.x; camera.tilt += mouse_force.y; wait (1); }
..............................
function fire_bullets()
{ VECTOR bullet_pos[3]; vec_for_vertex(bullet_pos, guard, 6); ent_create("bullet.mdl", bullet_pos, move_bullets); while(mouse_mode = 1) { vec_to_angle(guard.pan,mouse_dir3d); wait(1);
}
Last edited by Ted22; 12/27/09 22:29.
|
|
|
Re: My bullets don't go to the middle of the crosshair.Look ->
[Re: Ted22]
#303298
12/27/09 22:44
12/27/09 22:44
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
oh, sorry I didn't see that you use the crosshair as the mouse map but when i look at your code again, i see many many mistakes! first: not VECTOR bullet_pos[3] because you don't need an vector array! --> VECTOT bullet_pos; second: while(mouse_mode = 1) that is no comparision --> while(mouse_mode == 1) but why do you need that? if you want an endless loop use while(1) third: you turn your guard, not the bullet! --> vec_to_angle(your_bullet.pan, mouse_dir3d); now to your problem: use this: VECTOR temp; temp.x = mouse_pos.x - bmap_width(mouse_map)/2; temp.y = mouse_pos.y - bmap_height(mouse_map)/2; temp.z = 5000; vec_to_screen(temp, camera); c_trace(guard.x, temp, 0); vec_set(temp, target.x); vec_sub(temp, guard.x); vec_to_angle(guard.pan, temp); i hope i understand you right 
|
|
|
Re: My bullets don't go to the middle of the crosshair.Look ->
[Re: Rei_Ayanami]
#303304
12/27/09 23:10
12/27/09 23:10
|
Joined: Dec 2009
Posts: 74 Romania,Bucharest
Ted22
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2009
Posts: 74
Romania,Bucharest
|
Well,it's ur code is very logic but i guess i did something wrong...still doesen't works. (vec_to_angle(guard.pan,mouse_dir3d); <- i did it like this becos in another command to set bullet.pan = guard.pan;My code looks like this now: function fire_bullets()
{ VECTOR bullet_pos; vec_for_vertex(bullet_pos, guard, 6); ent_create("bullet.mdl", bullet_pos, move_bullets); while(1) { VECTOR temp; temp.x = mouse_pos.x - bmap_width(crosshair_pcx)/2; temp.y = mouse_pos.y - bmap_height(crosshair_pcx)/2; temp.z = 5000; vec_to_screen(temp, camera); c_trace(guard.x, temp, 0); vec_set(temp, target.x); vec_sub(temp, guard.x); vec_to_angle(guard.pan, temp); vec_to_angle(guard.pan,mouse_dir3d); wait(1);
} }
|
|
|
Re: My bullets don't go to the middle of the crosshair.Look ->
[Re: Ted22]
#303309
12/27/09 23:32
12/27/09 23:32
|
Joined: Mar 2007
Posts: 112
MikeS
Member
|
Member
Joined: Mar 2007
Posts: 112
|
Well,it's ur code is very logic but i guess i did something wrong...still doesen't works. (vec_to_angle(guard.pan,mouse_dir3d); <- i did it like this becos in another command to set bullet.pan = guard.pan;My code looks like this now: function fire_bullets()
{ VECTOR bullet_pos; vec_for_vertex(bullet_pos, guard, 6); ent_create("bullet.mdl", bullet_pos, move_bullets); while(1) { VECTOR temp; temp.x = mouse_pos.x - bmap_width(crosshair_pcx)/2; temp.y = mouse_pos.y - bmap_height(crosshair_pcx)/2; temp.z = 5000; vec_to_screen(temp, camera); c_trace(guard.x, temp, 0); vec_set(temp, target.x); vec_sub(temp, guard.x); vec_to_angle(guard.pan, temp); // vec_to_angle(guard.pan,mouse_dir3d); wait(1);
} } vec_to_angle(guard.pan,mouse_dir3d); try with commenting this out, you set the pan of the guard again on the pan of mouse_dir3d which is the upper left corner of your mouse map. With this vec_to_angle(guard.pan, temp); you set it to the middle of the crosshair how i understand this. If you then use bullet pan = guard pan, it should work i think
|
|
|
|