O'Reilly logo

UnrealScript Game Programming Cookbook by Dave Voyles

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a crosshair

One of the most valuable bits of information in a first person shooter is the crosshair. This is obviously important for knowing exactly where our shots will land and where our pawn is focusing its attention.

We're going to be drawing a crosshair directly in the center of the screen, which is precisely where our projectiles will be firing.

Getting ready

Open your IDE and have the TutorialHUD class ready to edit. We're going to be adding quite a few variables here.

How to do it...

To create crosshairs we'll need to declare variables which store our data, as well as a function to draw the actual crosshair. We'll then take our newly created DrawWeaponCrosshair() function and add it to DrawHUD(), so that it gets drawn on screen with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required