Book Image

Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide

By : Rachel Cordone
Book Image

Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide

By: Rachel Cordone

Overview of this book

Unreal Development Kit is the free edition of Unreal Engine—the largest game engine in existence with hundreds of shipped commercial titles. The Unreal Engine is a very powerful tool for game development but with something so complex it's hard to know where to start.This book will teach you how to use the UnrealScript language to create your own games with the Unreal Development Kit by using an example game that you can create and play for yourself. It breaks down the UnrealScript language into easy to follow chapters that will quickly bring you up to speed with UnrealScript game programming.Unreal Development Kit Game Programming with UnrealScript takes you through the UnrealScript language for the Unreal Development Kit. It starts by walking through a project setup and setting up programs to write and browse code. It then takes you through using variables, functions, and custom classes to alter the game's behavior and create our own functionality. The use and creation of Kismet is also covered. Later, using replication to create and test multiplayer games is discussed. The book closes with code optimization and error handling as well as a few of the less common but useful features of UnrealScript.
Table of Contents (18 chapters)
Unreal Development Kit Game Programming with UnrealScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – Using floats


Floats are used when we need something that doesn't have nice neat values, like how far away something is or how accurate a weapon is. They're declared the same way as our bools and ints, so let's make one now.

  1. Replace our int declaration with this:

    var float DistanceToGo;
  2. Floats have a default value of 0.0. Let's change our PostBeginPlay function to check this.

    function PostBeginPlay()
    {
       'log("Distance to go:" @ DistanceToGo);
    }
  3. Compile and test, and our log should look like this:

    [0007.61] ScriptLog: Distance to go: 0.0000
  4. We can see that unlike ints, floats will log with a decimal place. Let's see if we can change the value. Add this line to the beginning of our PostBeginPlay function:

    DistanceToGo = 0.123;
  5. Compile and test, and we should see the fraction show up in the log:

    [0007.68] ScriptLog: Distance to go: 0.123
  6. Let's see what happens when we use the same line we did for our int. Change the line to this:

    DistanceToGo = 10 / 3;
  7. Compile and test, and our log should...