Hello,
i hope that you are able to help me. I'm working on a bow/arrow script using the physic engine. My problem is that I am not able to let the arrow fly in the right direction where i point with the camera.
I tried this function for the arrow:
function physikpfeil2()
{
pfeil2 = me;
var temp[3];
phent_settype(my,PH_RIGID,PH_BOX);
phent_setmass(my,5,PH_BOX);
phent_setelasticity(my,10,5);
phent_setfriction(my,30);
phent_setdamping(my,5,3);
while(vec_dist (my.x, player.x) < 10)
{
vec_set(my.pan,camera.pan);
vec_rotate(shot_speed,camera.pan);
if (vec_dist (my.x, player.x) < 10) {my.passable = on;}
// vec_scale(temp[0],1000);
vec_normalize(shot_speed,1000);
phent_addcentralforce(my,shot_speed);
wait(1);
}
}
this is from where i get the vector:
my.skill44 = 0.5 * screen_size.x;
my.skill41 = 0.5 * screen_size.y;
my.skill42 = 20;
vec_set (my.skill43, my.skill40);
my.skill45 = 10000;
vec_for_screen (my.skill44, camera);
vec_for_screen (my.skill43, camera);
trace_mode = ignore_me + ignore_passable;
target = trace (my.skill44, my.skill43);
vec_set (gun_target, target);
vec_diff (shot_speed, gun_target, player.pos); vec_normalize(shot_speed, 10000000);
I this is how the arrow is created
ent_create(arrow_mdl,camera.x,physikpfeil2);
I think that this is not a very good solution for the problem... and it doesn't work...
Does somebody has a better solution for the problem??
Thank you very much!