Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
movable crosshair and weapon #254253
03/02/09 00:50
03/02/09 00:50
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
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

Re: movable crosshair and weapon [Re: GameScore] #254260
03/02/09 07:04
03/02/09 07:04
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
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.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1