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

Changing the crosshair color when aiming at a pawn

Now that we have a more accurate representation of our crosshair working, why not take it to the next step and have it change colors to signify that we are pointing at a pawn?

In this next recipe, we'll add behavior to our crosshair that allows us to do just that.

Getting ready

Start by having your IDE open and ready to make some changes. We won't have to create any new classes, as we'll only have to make changes to an existing function in our TestHUD class.

How to do it...

This change requires us to add an if statement to our CheckCrosshairOnFriendly().

  1. Let's add it now as shown in the code snippet:
     /** If our trace hits a pawn... */ if ((Pawn(HitActor) == None)) { /** Draws the crosshair for no one ...

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