Creating a Simple In-Game Editor in UDK


Any video game has a number variables that can be tweaked to affect the game experience. Often, adjusting these values is a trial-and-error process of iterating until the game just feels right. It’s common practice to implement a way of doing such tweaking without having to restart the game to see changes take place: an in-game editor.

The UDK provides several utilities for editing objects and actors on-the-fly. You can use these utilities to quickly implement a tweaking interface to allow game designers on your team to easily adjust game parameters in realtime.

The core of UDK’s realtime tweaking capabilities is a feature called Remote Control. Starting UDK.exe with Remote Control enabled opens up a window alongside the game which allows you to change graphics settings, inspect and edit active actors, and toggle stat captures. Activating Remote Control also enables a series of console commands that can allow runtime editing of almost any instantiated object, actor, or archetype.

For example, you may want to implement an object that contain a categorized list of the various global tuning parameters you expose in your game. These numbers could represent values that will eventually be constants in your game system but will need significant iteration in order to find the right mix for your game.

First of all, you’ll need to be able to start your game with Remote Control enabled. In my case, I edit my UDK launch batch file to add “-remotecontrol” argument when launching UDK.exe:

Binaries\Win32\UDK.exe %start_map% -remotecontrol

Next, create an object to contain the parameters that you want to expose to your game designers. By using the “var(category)” syntax for declaring members, you can organize them into collapsable tabs. For arrays of objects, the “editinline” modifier makes it possible for designers to edit the objects contained within the array (as opposed to just the array itself.)

//Class written as example for blog article on creating an in-game editor
class TestGame_GameParameters extends Object;

var(Players) float PlayerHealthMultiplier;
var(Players) float PlayerSpeedMultiplier;
var(Players) float PlayerAttackMultiplier;

var(Enemy) float EnemyHealthMultiplier;
var(Enemy) float EnemySpeedMultiplier;
var(Enemy) float EnemyAttackMultiplier;

var(Weapons) editinline array WeaponAttacks;
var(Weapons) float SecondsPerWeaponBeat;

defaultproperties
{
	Begin Object Class=TestGame_InstantHitAttack Name=Attack1
		AttackName="OverhandLight"
		Damage=1.0
		Duration=1.0
		Cooldown=1.0
	End Object
	WeaponAttacks.Add(Attack1)

	Begin Object Class=TestGame_ProjectileAttack Name=Attack2
		AttackName="Fireball"
		Damage=4.0
		Duration=2.0
		Cooldown=3.0
	End Object
	WeaponAttacks.Add(Attack2)

	Begin Object Class=TestGame_InstantHitAttack Name=Attack3
		AttackName="OverhandHeavy"
		Damage=2.0
		Duration=1.0
		Cooldown=1.0
	End Object
	WeaponAttacks.Add(Attack3)

	PlayerHealthMultiplier = 1.0f
	PlayerSpeedMultiplier = 1.0f
	PlayerAttackMultiplier = 1.0f

	EnemyHealthMultiplier = 1.0f
	EnemySpeedMultiplier = 1.0f
	EnemyAttackMultiplier = 1.0f
}

With the game parameters object defined, it’s time to instantiate it in some easily accessible global space: GameInfo, for example.

class TestGame_GameInfo extends SimpleGame;

var TestGame_GameParameters GameTuningParameters;

//...

defaultproperties
{
	Begin Object Class=TestGame_GameParameters Name=GameParameters0
	End Object
	GameTuningParameters=GameParameters0
}

It’s important to note the name of the game parameters object instantiated in defaultproperties, “GameParameters0″. You’ll be able to use this name as a parameter to the “editobject” command to directly address your parameter object.

At this point, you can edit your game parameters object in-game by hitting tab and entering “editobject GameParameters0″. Doing so will open a property grid targeting your global instance of TestGame_GameParameters.

Of course, typing in “editobject GameParameters0″ tweak values is a nuisance and we don’t want anything discouraging your game designers from using the tools you’ve built. To make it easier for them, we can take an extra step and make the game parameter property grid accessible with a single button press.

By editing DefaultInput.ini, you can set up a key binding like so:

;-----------------------------------------------------------------------------------------
; Game Keyboard/Mouse Bindings
;-----------------------------------------------------------------------------------------

; Binding for tweaking ingame parameters (written for blog post)
.Bindings=(Name="F9",Command="TweakGameParameters")

With the above setting, pressing F9 will call an exec function called TweakGameParameters(). After that, it’s just a matter of defining said function:

class TestGame_PlayerControler extends PlayerController;

exec function TweakGameParameters()
{
   ConsoleCommand("editobject GameParameters0");
}

And that’s it! Now, your team’s game designers will be able to press F9 while the game is running to bring up a property grid for tweaking game parameters on-the-fly.

Share this Article:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Print