make an entity and move it in the right direction. To do this, make a new function called "iKillYou()" and attach it to the entity you created. In this function, you put the entity at the start position of the c_trace. Then, using vec_to_angle and the direction between start and endpoint of the c_trace, turn the model towards the end position of the c_trace. Your bullet is now created and faces the target.

The following depends on how you want the bullet to function. Should it hit obstacles that come in the way while moving in the path of the bullet, or is it just a straight line reaching the c_trace target whatever is inbetween? The first is somewhat complicated, the latter is the quickest.

For shooting at a target where the bullet will always reach the target of c_trace:
Code:

//psuedo code
function iKillYou
while (target != reached) {
bullet.angle = vec_to_angle(dirVecToTarget) //bullet faces target of the c_trace (dirVecToTarget = direction from start to end of c_trace)
bullet.position += vec_normalize (dirVecToTarget, speed) //now move forward by adding the direction vector, multiplied by the speed of the bullet
}



EDIT:
as a side note, you can pass the direction vector and player angles to the function immediately as well of course, which spares some calculations with vec_for_angle and vec_to_angle. Probably a better way as you need less calculations and code. Hope that will help you enough to find out yourself.

Last edited by Joozey; 11/20/07 15:04.

Click and join the 3dgs irc community!
Room: #3dgs