I am creating a 3D asteroids game. I got the bullets, asteroids, and ship all done. They work perfectly. Now I want a crosshair to display where the ship is pointing at. The crosshair will be a 2D sprite.
Here is what I want:
|
I am creating a 3D asteroids game. I got the bullets, asteroids, and ship all done. They work perfectly. Now I want a crosshair to display where the ship is pointing at. The crosshair will be a 2D sprite. Here is what I want: |
|||||||||||
|
|
You could fire an invisible infinite speed bullet from you ship during every frame, and if it hits an asteroid (or the edge of the viewport/frustum), draw your cross-hair sprite at that point. The advantage of this is that you can use your already existing bullet firing, collision detection, and hit effect code, so you should have practically zero overhead effort. If you use this approach and your collision detection code cannot handle overshooting bullets, you either have to adjust that code or use a special method to handle that bullet, although you should probably do the former. You didn't specify, but if by "3D game" you mean a first person perspective, then you can simply draw that sprite in the middle of the screen or at the position of your mouse pointer. |
|||
|
|