UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Miscellaneous Recipes


232


  1. Compile the project and see for yourself. If you run your crosshair over another pawn
    it will turn yellow!


How it works...


We add a simple if statement to check if the trace from our weapon has run across a pawn.
If it has, then we draw a yellow crosshair. If not, we default to our gray crosshair.


Drawing a debug screen


UDK offers easy access to a plethora of debug options through the console commands. While
this is useful, it can be tedious to constantly type in these commands. What if there was a
more effective way to draw our debug options for individuals who may not be as savvy with
programming, like a level designer?


As a programmer, one of your many roles may include supporting designers and creating
tools. To make their world easier we'll be creating a debug menu that can be accessed with
one key and allow access to a number of debug options. This is great in situations where you
don't have a keyboard available, such as when you are demoing a project with a game pad.
We'll bind them to keyboard keys for now, but understand that they can just as easily be done
with the game pad.


Getting ready


Start by having your IDE open and ready to make some changes. We'll be creating a new
class, as well as a new function in our HUD, and adding some game bindable actions in
our defaultInput.ini file.

Free download pdf