Hi,

I have been trying to implement Half-life 2 picking up of objects
and throwing them. I have been able to do things properly to a point and now
there is a small issue which isnt allowing me to complete things.

I pick up the object and also can move around with it. But when I throw it in some random direction ( camera's direction)
the object is restored to it's original pickup position and then physics is applied to it.

I am at a loss to understand why this is happening.

Here is the code below :

sound sound_hit_metal = <hit.wav>;
var alreadylifted = 0;
var thrownow = 0;


function ball_event()
{

if(event_type == event_shoot && alreadylifted ==1)
{
beep();
return;
}

if(event_type == event_shoot && alreadylifted ==0)
{
currentphysicsobject = me;

thrownow=0;
//breakpoint;
while(thrownow==0)
{

temp.x = 100;
temp.y=0;
temp.z=0;
vec_rotate(temp,camera.pan);
vec_set(currentphysicsobject.x,you.x);
//vec_set(my.x,you.x);
vec_add(currentphysicsobject.x,temp.x);
//vec_add(me.x,temp.x);
alreadylifted=1;
wait(1);
}
//phent_addforcelocal ( my, vector(5000,0,0),target);
//snd_play(sound_hit_metal,sound_vol,0);
//alreadylifted =1;

}

//(event_type == event_shoot && alreadylifted ==1)
if(alreadylifted ==1)
{
breakpoint;
thrownow = 1;
temp.x = 10000;
temp.y = 0;
temp.z =0;
//wait(1);
vec_rotate(temp,camera.pan);
//phent_addforcelocal(me,vector(5000,0,0),me.x);
//phent_addcentralforce(currentphysicsobject,temp);
phent_addforcelocal(currentphysicsobject,temp,currentphysicsobject.x);
//snd_play(sound_hit_metal,sound_vol,0);
alreadylifted = 0;

}
}

function resetobject()
{
//vec_set(temp,my.x);
if(alreadylifted ==0)
{

return;
}
thrownow = 1 - thrownow;
wait(1);
ball_event();
//wait(1);

}
action my_ball
{
phent_settype(my, PH_RIGID, PH_BOX);
phent_setmass(my, 100, PH_BOX);
phent_setfriction(my, 30);
phent_setelasticity(my, 20, 10);
phent_setdamping(my, 30,100);
ph_setgravity( vector(0,0,-386));
my.enable_shoot = on;
my.event = ball_event;
my.shadow=on;
on_mouse_left = resetobject;

}

thanks in advance for any help

I am using WINxP and A 6.30.0


Best Regards, Sichlid