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 that uses our weapon's trace

We've previously covered crosshairs and aiming in other recipes, but we're going to handle it in a different manner now. Rather than always have our pawn fire at the direct center of the screen, we'll change some behaviors so that our projectiles fire using the gun's rotation. Both look and feel more accurate and realistic.

We'll do this by drawing a trace from the barrel (socket) of our weapon, and using the weapon's rotator to draw the crosshair at the end of the trace.

Getting ready

Start by having your IDE open and ready to make some changes. We won't have to create any new classes, but we will alter the behavior of our existing ones by adding some functions.

How to do it...

  1. The first thing we ...

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