Posted By: CD_saber
Why does it not fly? PLEASE HELP - 08/21/08 13:34
Hello,
i'm using an cscript version of the throw object code from the wiki(for a bow code). The strange thing is that it works fine when I do not use a player/camera code. But when I want to use my player code and press the throw key, the arrow is created but stays motionless in the air.. please can somebody help me, what is the problem?
here is both the throwing code and the player script:
function Phy_debug_throw()
{
var flyvec[3];
vec_set(earthgravity, vector(0,0, -386));
while(1)
{
if(mouse_left)
{
you = ent_create("pfeil.mdl",camera.pos,NULL);
c_setminmax(you);
vec_set(you.pan,camera.pan);
ph_setgravity(earthgravity);
phent_settype(you,PH_RIGID,PH_BOX);
phent_setmass(you,2,PH_BOX);
phent_setelasticity(you,5,100);
phent_setfriction(you,60);
phent_setdamping(you,60,80);
flyvec[0] = 1;
flyvec[1] = 0;
flyvec[2] = 0;
vec_rotate(flyvec[0],camera.pan);
vec_scale(flyvec[0],300000);
phent_addcentralforce(you,flyvec[0]);
wait(-0.2);
}
wait(1);
}
}
Player script:
function camera_move()
{
while(player)
{
camera.pan += 0.5 * ang(player.pan - camera.pan);
vec_set(camera.x,player.x);
camera.z += 60; ///+ sin(total_ticks * 10);
mouse_mode = 0;
wait(1);
}
}
Action player_move()
{
var reldist[3];
var absdist[3];
var input_vec[3];
var Vz = 0;
var jump_able = 1;
my.invisible = on;
player = me;
camera_move();
while(me)
{
vec_set(reldist.x,nullvector);
input_vec.x = (key_w - key_s) * time * 30;
input_vec.y = (key_d - key_a) * time * -18;
my.pan -= 30 * mouse_force.x * time;
camera.pan = my.pan;
camera.tilt = min(max(ang(camera.tilt + 30 * mouse_force.y * time),-60),60);
Vz += (Vz == 0) * 100 * key_space * jump_able;
if(Vz > 0)
{
jump_able = 0;
}
Vz -= (Vz > 0);
c_move(me,input_vec,nullvector,GLIDE);
c_move(me,nullvector,vector(0,0,(Vz - 35) * time),0);
if(trace_hit)
{
jump_able = 1;
}
wait(1);
}
}
i'm using an cscript version of the throw object code from the wiki(for a bow code). The strange thing is that it works fine when I do not use a player/camera code. But when I want to use my player code and press the throw key, the arrow is created but stays motionless in the air.. please can somebody help me, what is the problem?
here is both the throwing code and the player script:
function Phy_debug_throw()
{
var flyvec[3];
vec_set(earthgravity, vector(0,0, -386));
while(1)
{
if(mouse_left)
{
you = ent_create("pfeil.mdl",camera.pos,NULL);
c_setminmax(you);
vec_set(you.pan,camera.pan);
ph_setgravity(earthgravity);
phent_settype(you,PH_RIGID,PH_BOX);
phent_setmass(you,2,PH_BOX);
phent_setelasticity(you,5,100);
phent_setfriction(you,60);
phent_setdamping(you,60,80);
flyvec[0] = 1;
flyvec[1] = 0;
flyvec[2] = 0;
vec_rotate(flyvec[0],camera.pan);
vec_scale(flyvec[0],300000);
phent_addcentralforce(you,flyvec[0]);
wait(-0.2);
}
wait(1);
}
}
Player script:
function camera_move()
{
while(player)
{
camera.pan += 0.5 * ang(player.pan - camera.pan);
vec_set(camera.x,player.x);
camera.z += 60; ///+ sin(total_ticks * 10);
mouse_mode = 0;
wait(1);
}
}
Action player_move()
{
var reldist[3];
var absdist[3];
var input_vec[3];
var Vz = 0;
var jump_able = 1;
my.invisible = on;
player = me;
camera_move();
while(me)
{
vec_set(reldist.x,nullvector);
input_vec.x = (key_w - key_s) * time * 30;
input_vec.y = (key_d - key_a) * time * -18;
my.pan -= 30 * mouse_force.x * time;
camera.pan = my.pan;
camera.tilt = min(max(ang(camera.tilt + 30 * mouse_force.y * time),-60),60);
Vz += (Vz == 0) * 100 * key_space * jump_able;
if(Vz > 0)
{
jump_able = 0;
}
Vz -= (Vz > 0);
c_move(me,input_vec,nullvector,GLIDE);
c_move(me,nullvector,vector(0,0,(Vz - 35) * time),0);
if(trace_hit)
{
jump_able = 1;
}
wait(1);
}
}