| Home Page | Recent Changes

Making New Input Commands

Tutorial: Making new input commands [Written for UT2004 but it should work in UT2003/UT99]

Author: James Tan aka Solid Snake

Last update: 27/5/2004

Introduction

Sometimes when you are making a new game/mod it is possible that you may need to add in extra keys to allow the player to do more things at once. Adding these into the Unreal engine is very easy, although the way it actually works is a little strange at first, but hopefully after this tutorial it should be no problems.

Toggle input

Togglet inputs are ones that the user simply had to push the button and Unreal will do something. There are no special conditions for these types of inputs as well as the fact that these are the most simplistic types of inputs. These keys are things such as Esc for the menu, or F4 for the first person camera view. To add these into Unreal is a two step process, the first step is to make the exec function within a player owned class and then making a physical bind between Unreal and the user through the User.ini.

Step 1: Making the exec function

exec function OpenMenu(optional float F)
{
  if(F == 1)
    // Run this line.
  else
    // Run this line.
}

Step 2: Editing the user.ini.

From here, you now need to assign a key to this function. Simply open up the user.ini file, and look for a free key. An example is something like 'B='. Just add in your function name, so it looks like 'B=OpenMenu'. Now when you press B, it will run your function, provided that the player is controlling the class which has this function defined in it. Note that I have added an optional float in the syntax of the function. To parse a value into the function, simple write the number like so, 'B=OpenMenu 1'. That way you can have multiple keys which all do similar things but you can differentiate between the keys. This is how weapon switching is done.

Sustained inputs

Sustained are useful when you want to know if the player is holding onto a key or not, so these would encompasses movement type keys, time dependent keys and weapon related keys. Basically, if you need a key which requires the player to hold onto the key then this is where you want it to be. However this is a little but more complicated as such, since more scripts will need to be created. This of course is just the way I do it, and there can be more than one way.

Step 1: Making your input variable

var input byte bHoldMenu;

This should go in a class which the player has control of, thus the immediately obvious ones are ones such as PlayerController. Now, what we need to do is to monitor this value. We don't have to do anything else other than that, since Unreal will automatically alter this variable when a key is pressed.

Step 2: Monitoring your new input variable.

function PlayerTick(float DeltaTime)
{
  Super.PlayerTick(DeltaTime);
  if(bHoldMenu == 1)
    // Key pressed down/held down. Run this line.
  else
    // Key released or not pressed. Run this line.
}

As you can see here, I have monitored the input variable in the PlayerTick function which is of course in my own PlayerController class.

Step 3: Assigning a key to your new input variable.

Now, open up your User.ini file and append to the current ... Argh I forgot this! Will update when I remember or have a user.ini in front of me.

For those that kind of know what I mean, you have to make a new command and bind it to an alias. You then bind a key to the alias and not the input variable.

- Still needs work!

Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In