On target?

Blitz3D Forums/Blitz3D Programming/On target?

Jerome Squalor(Posted 2007) [#1]
You know how in any shooter game there is a little image on the screen to show where your bullet is gonna go when you shoot? Like a thing that helps you aim. It is usually at the center of the screen.
Well, how do you actually make the 3D bullets go to the center of the screen?


boomboom(Posted 2007) [#2]
if you fire your bullet from the camera, rather than the gun model, they will go to the center


Jerome Squalor(Posted 2007) [#3]
I meant from a gun or any other object


boomboom(Posted 2007) [#4]
Yes, you can still have the gun animated so it looks like it comes from it, but instead have the bullet come from the camera.

You can set the alpha of the bullet to 0 so its not visible as well.


cash(Posted 2007) [#5]
There may be better ways however:

I generally create two spheres

one at the tip of the gun parented to the gun and one which is positioned in the z axis at a distance which lines up with the fixed hud graphic when viewed. This second sphere is parented to the first sphere.

get the co-ordinates for the first sphere and use this as the start position for the bullet. point the bullet towards the second sphere and move it . When it collides with the second sphere delete the bullet.

A bit crude but it works. Obviously entityalpha the spheres as 0.


boomboom(Posted 2007) [#6]
The trouble with that is its only acurate for the distance the second sphere is. If the enemy is closer or further it will be inacurate.


Ross C(Posted 2007) [#7]
A tricky problem when you think about it. Unless, as boomboom says, you make your bullet come from the camera's centre point, your bullet is only going to hit the target at one point on it's journey.

You could try auto-aim lock. Where you lock onto a target, and the bullet travels towards that target.


Dreamora(Posted 2007) [#8]
the simple way to get it going there is to use aligntovector and use the vector from cam to this point (pickedXYZ after you used linepick to get this red point) and just let the projectile move into z direction.


Ross C(Posted 2007) [#9]
Best limit the length of your picks though, as it could be costly outdoors :D