crosshair problem

Posted By: GameScore

crosshair problem - 07/22/11 21:04

hi,
hope someone can help me,
got a problem with a 1st person shooter projekt
i created a gun with a c_trace now i want to craete a panel or a view entity as crosshair

can someone help me?
Posted By: Espér

Re: crosshair problem - 07/22/11 23:42

i think you need to make use of this: http://www.conitec.net/beta/avec_to_screen.htm
to get the screen coordinates from the players view to 2D, to show the panel at the returned XY coords..
Posted By: 3run

Re: crosshair problem - 07/23/11 05:44

Why don't just plase panel at the center of the screen? What for he needs avec?
Posted By: GameScore

Re: crosshair problem - 07/23/11 12:16

Hi,
i was try to do this with vec_for screen
but it doesnt work
did you have a code sample for me
maybe i forgot something or do something wrong

Code:
vec_set(crosshair,target);
      vec_for_screen(crosshair,camera);


Posted By: 3run

Re: crosshair problem - 07/23/11 13:03

Why you need to set panel on target? Just place it in the middle of the screen. Do you need me to show you how to do that?
Posted By: GameScore

Re: crosshair problem - 07/23/11 13:57

hi,
i know how to set a statical panel or view entity
i try to explain what i mean

my weapon is a view entity
but its not statical
i can move the gun on pan and tilt
and from gun.x there goes a c_trace to gun.x+10000
this is where the bullet fly if i shot
and now i need a panel who follows the target point
but the problem i have is to bring the world coords to screen coords
i was try to create an entity on target.x
it works fine but the problem ist if the distance between the gun and the target point grows, the entity scaled down

so i need a panel or something like this who follows the target point on the screen coords

got me?
Posted By: 3run

Re: crosshair problem - 07/23/11 14:12

gun.x is a view entity?
Anyway, try this one (not tested):
Code:
// here is your trace
if(trace_hit)
{
    vec_set(temp,target.x);
    vec_to_screen(temp,camera);
    panel.pos_x = temp.x;
    panel.pos_y = temp.y;
}

I hope this works. Please notice that you need to use "vec_to_screen" not "vec_for_screen", read manual carefully.
Posted By: GameScore

Re: crosshair problem - 07/23/11 14:50

how can i use a panel?
i was try with an view entity
but it doesnt work
and i have no idea how to do with an panel
Posted By: 3run

Re: crosshair problem - 07/23/11 15:14

Just make panel:
PANEL* test =
{
bmap = insert bmap
flags = SHOW;
}
And try to use script I gave you.
Posted By: GameScore

Re: crosshair problem - 07/23/11 19:07

works awesome!
thank you man!

so simple
how i could be so stupid
a flash should hit me when i crap
Posted By: 3run

Re: crosshair problem - 07/23/11 19:15

You are welcome dude.
© 2023 lite-C Forums