Game Development Reference
In-Depth Information
Once you've hardcoded some values that seem to work for a new camera system (that is, third
person), you can then create a Boolean in these properties that allow you to quickly switch it
on and off with the touch of a button.
Add the following to the variables section of your TutorialCameraProperties class:
/** If true, then use the third person settings */
var(Camera) constboolUseThirdPerson;
Afterward, add the following to your TutorialCamera class, just
beneath where we've stated If (Pawn != None):
/** Be sure to set the values in your camera within the editor
to 0! Otherwise this will not work correctly! If the
camera properties forces the camera into third person,
then extract it now */
if (CameraProperties.UseThirdPerson)
OutVT.POV.Location.X += 120;
OutVT.POV.Location.Y += 50;
OutVT.POV.Location.Z += 35;
OutVT.POV.Rotation.Roll += 0.0f;
OutVT.POV.Rotation.Pitch += 0.0f;
OutVT.POV.Rotation.Yaw += 10.0f;
// Hide the pawn's "first person" weapon
if(Pawn.Weapon != none)
Selecting the checkbox in your editor within the game will now instantly transform your
camera into a third person view!
How it works...
Our camera properties class is simply an object that attaches to our Camera class and allows
us to alter our camera's properties from within the editor. We've created an archetype from
our CameraProperties class, so that we can reference it from UScript and attach it to our
Camera class through our default properties.
Attaching our CameraProperties archetype to our camera allows us to make changes on
the fly within the editor, and remove the frustration of needing to go back and forth between
our IDE, recompiling, and then the editor to see any changes take place.
Search Nedrilad ::

Custom Search