Hi there
i need help in scripting a good bow and arrow script. At the moment i´m using this!
That is for creating the arrow:Code:
function bowarrow()
{
while (1)
{
if (mouse_left == 1 && arrowfired != 1) // Check something
{
vec_set (temp, camera.pos); // Arrow start at camera
ent_create (arrows, temp, move_arrow); // create arrow
arrowmenge += 1; // variables
arrowfired = 1; // variables
}
wait(1);
}
}
That is for moving the arrow:Code:
action move_arrow()
{
fire_spur(); // particles
my.enable_block = on;
my.event = hurt_you;
my.pan = camera.pan;
my.tilt = camera.tilt;
my.firespeed = 80; // Defined
my.schwerkraft = 0; // Gravity
while (my.firespeed != 0) // moves until it hits something
{
if (vec_dist (my.x, player.x) < 100) // Make it passable if it collides with player
{
my.passable = on;
}
else
{
my.passable = off;
}
ent_move (vector(my.firespeed, 0, my.schwerkraft), nullvector); // move it!
my.schwerkraft -= 1*time_step; // add gravity to pull it down
wait (1);
}
}
That is for removing arrow on event:Code:
function hurt_you()
{
if (EVENT_TYPE == EVENT_BLOCK)
{
my.firespeed = 0; // stop the arrow
sleep(3); // show the impact for 3 seconds
ent_remove(my); // remove arrow
arrowmenge -= 1;
wait(1);
}
}
That code works fine but the problem is that the arrows stop a little bit before the wall. I want that they put in the wall.
Another problem is that the tilt of the arrow is only turned to the tilt position at the beginning shoot if the gravity pulls it down to earth it looks in the air. How can i turn it while he´s flying to the ground.
Here is a pic of the arrow in wall:
![](http://www.raschfilms.com/arrowinwall.jpg)
Another question: Do you know other better Bow and Arrow Solutions?
And another one: How about trying with Physic Objects? And if yes how to do it?
Thank you guys!