UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 3

63

Camera properties and archetypes


With our Camera class in place, we now need to create a class for our publicly exposed
properties, as well as the archetype that we'll physically interact with, inside the UDK editor.


Getting ready


Open your IDE and prepare to create a new class.


How to do it...


Exposing properties to the editor can be a far easier way to make tweaks and changes to
actors like our camera. Without this archetype we are about to build, we'd have to manually
change the variable within our IDE, compile the project, then view our results in the editor.
We plan on making the life of your level designer much easier with this simple fix.


In the following recipe we'll need to create a new class, in addition to an archetype within
the UDK editor, so that our level designers can reference our class without ever having to
open up an IDE:



  1. Create TutorialCameraProperties.uc in our Classes folder (C:\UDK\July\
    Development\Src\Tutorial\Classes).

  2. As we're simply making an archetype, we'll be extending our class from the most
    basic of all UDK classes, Object.
    class TutorialCameraProperties extends Object

  3. Moreover, we want to keep our editor as clean as possible, so we'll be hiding all
    of the camera's properties with this next step.
    /* We don't want to clutter up the editor, so hide Object
    categories
    /
    HideCategories(Object);

  4. Moving on, we'll want to expose only the variables we've created in our
    TutorialCamera class. This allows us to easily and quickly make changes
    to nearly anything we would want to change for our camera. All of these variables
    were previously defined in our TutorialCamera class.
    / Camera offset to apply */
    var(Camera) const Vector CameraOffset;
    /* Camera rotational offset to apply /
    var(Camera) const Rotator CameraRotationOffset;
    /
    Pawn socket to attach the camera to */
    var(Camera) const Name PawnSocketName;
    /* If true, then always use the target rotation /
    var(Camera) constboolUseTargetRotation;

Free download pdf