movable crosshair and weapon

Posted By: GameScore

movable crosshair and weapon - 03/02/09 00:50

hi, i have a big problem and i find no solution
i want to create a 1st person shooter with a movable crosshair and weapon
now i have some codes but the codes dont run perfect
the code for the crosshair dont work in my templates only with the lite_c workshop 14
and the code for my movable gun drives my gun crazy crazy

when i walk forward the gun goes downward and when the player rotates the gun rotates in 360°and the gun and the crosshair are not synchronic
i hope someone can help me

1st the code for my crosshair who will still not work in my template only in the lite_c workshop 14
i include the code to my script, i get no error messages but i see no effect
//////////////////////////////////////////////////////////
starter mouse_kinetics// crosshair follows the mouse
{
var delta_x;
var delta_y;
var cross_speed;
var range_size_x;
var range_size_y;

cross_speed=10;
range_size_x=300;
range_size_y=200;

while (1)

{


delta_x+=mouse_force.x*cross_speed; //set cross_speed to 1, c
delta_y-=mouse_force.y*cross_speed;


delta_x= clamp(delta_x, (screen_size.x*0.5) - range_size_x, (screen_size.x*0.5) + range_size_x);
delta_y= clamp(delta_y, (screen_size.y*0.5) - range_size_y, (screen_size.y*0.5) + range_size_y);

mouse_pos.x = delta_x-bmap_width(crosshair_pcx)*0.5;
mouse_pos.y = delta_y-bmap_height(crosshair_pcx)*0.5;
camera.pan -= mouse_force.x;
camera.tilt += mouse_force.y;

wait (1);
}

}

this code works in my templates for the movable crosshair, but not perfect
starter move_panel // crosshir follows the mouse
{
{
var pan_pos[3];
while(1) {

pan_pos.x = (mouse_cursor.x*((screen_size.x-700)/screen_size.x))+275;
pan_pos.y = (mouse_cursor.y*((screen_size.y-400)/screen_size.y))+100;
plBipedWeap00_crosshair1_pan.pos_x = pan_pos.x;
plBipedWeap00_crosshair1_pan.pos_y = pan_pos.y;

wait(1);
}
}

and now the code for my movable gun, i can move the gun and the player with the mouse together
but the gun turns on 360° when i rotate the player
and its not synchronic with the crosshair

starter set_weap_entpos // Gun follows the crosshair
{
var vec_from[3];
var vec_to[3];
proc_late();

while(1)
{
if(plBipedWeap00_curr_weap != NULL)
{
vec_set(vec_from, vector(plBipedWeap00_crosshair1_pan.pos_x, plBipedWeap00_crosshair1_pan.pos_y, 50));
vec_set(vec_to, vec_from);

vec_for_screen(vec_from, camera);
vec_to.Z = 8000;
vec_for_screen(vec_to, camera);

c_trace(vec_from, vec_to, IGNORE_ME|IGNORE_PASSABLE);

vec_set(temp, target);
vec_sub(temp, plBipedWeap00_curr_weap.x);
vec_to_angle( plBipedWeap00_curr_weap.pan, temp);
}
wait(1);
}
}

i hope for your help
hope for a solution cry
Posted By: jcl

Re: movable crosshair and weapon - 03/02/09 07:04

You posted to the wrong forum. The Developer forum is only for "tricky" questions that weren't answered in other forums. If you want other users to fix your code, please post to the "Starting" or "C-Script" forums.
© 2023 lite-C Forums