Steering Game Creator Character with Xbox Pad

Game Creator 1 is a powerful tool for Unity 3D that skyrockets your game production. With the press of one button, you can easily create a character and run around a scene. Nevertheless, you need to make a little more effort to make it work great on a gamepad using the standard input method. Fortunately, it’s not a big deal and all you need to do is set proper input values in Unity’s Project Settings.
- Basic locomotion and Camera
- Advanced locomotion – Jump
- Advanced locomotion – Sprint
- D-Pad actions
- Attack input
Basic Locomotion and Camera.
When you plug in an Xbox gamepad you can only walk around. No other input, like rotating the camera, jumping, and so on is available. It happens because moving is set to X and Y (or Horizontal and Vertical) Axis by default that is also set to Left Joy.
Before we go to set up a rotation of a camera with the right joy of a pad, let’s look at how’s Xbox layout translates to Unity’s Input Buttons:

To rotate the camera Game Creator is using mouseX and mouseY input axis. We have to make it work on the 3rd and 4th Joy Axis too. The simplest way to do this is to just duplicate Mouse X and Mouse Y inputs and change Type from Mouse Movement to Joystick Axis and set 4th and 5th axis accordingly.

It’s worth mentioning that if you want the exact behavior as Mouse Y moves, you should check the Invert tick in the input settings (see pic above).
Advanced Locomotion – Jump.
Great! Now, as we can walk and look freely, it’s time to set other custom actions to be executed on joypad button press like jumping, crouching, or fighting.
Let’s start with jumping as it is set to the space key in the Player Character component by default. It’s advisable to set it to none so later we can set it to any other key or button in the input settings.

Now we have to add a GC Condition and Action so the player character will jump. Before doing that, we need a custom Igniter that is available on Game Creator Hub that will allow us to choose input buttons instead of keys. Go to the hub and download the following addon:

Once it is imported to our Unity project (double click downloaded unity package) we are ready to push forward.
Create a new empty gameObject and add a Trigger component. Then change the trigger to Input > On Button Input. Select Button Type to Down and set Button Name to „Jump” (without quotes).
Now add the Action component to that object and set an action to Character > Character Jump. Alternatively, just search for Jump action.
As a result, we should have such components:

Ok, let’s make sure that our Jump Button is set correctly in the Input Manager of a Project Settings. In a new project, Unity should have two Jumps buttons prepared, one for the „space” key and another one for „joystick button 3” that is linked to the „Y’ button on the Xbox gamepad. If you want another button, just change the number to the one you like according to the Xbox layout shown above.

Advanced Locomotion – Sprint.
But what about sprinting? While playing on a keyboard it’s ok to hold a button for the player character to run, but holding a button on a gamepad may be tedious and tiring for a finger.
Because we use two different methods of input – press/release for a keyboard and on/off trigger for a gamepad – the best solution is to set two input buttons in the Input Manager. So, duplicate one of the buttons or add 2 more elements to the array and rename them to „Sprint” and „Sprint Gamepad”. Having one name, as we did in „Jump”, may complicate our life since we want different behavior for them.
No matter what input is made we will use the same actions for both. Let’s create two gameObjects with the Action component on them. One let’s name „Start Sprint” and the other „End Sprint”. For both actions let’s choose Character > Change Property. Set Target to „Player„, and Change Property to „Can Run„. On first set Value Bool to „true” and the other to „false„.

Now it’s time to set up triggers. Let’s start with Keyboard. Create a new gameObject and name it „Sprint Keyboard„. Add two Trigger components. For both change trigger to Input > On Button Input. For one choose Action Type „Down” and the other „Up” and set Key Button to „Sprint„. While we want to sprint when the left shift is held, we should drag and drop Start Sprint Action to the trigger with Down Action Type. The latter should have End Sprint Action linked. Our setup should look like the one below.

Now it’s time for the gamepad trigger. Here we need to use one Trigger and one Condition component. Change trigger to Input > Unity Input Button, choose Action Type Down, and for Key Button set „Sprint Gamepad„. This time the trigger does not execute action but should check for the condition if the player character is already running or not. So, instead of dragging previously prepared actions drag a Condition component as a result of a trigger.
In the Condition component add check for Character > Character Property, choose „Player” for Target, and property set to „Is Running„. Set Description text field to any you want e.g. „Check if is Running”. While we are checking if the player is already running drag and drop „End Sprint” action to Then field and „Start Sprint” action to Else field of the condition.

Uff… no we are ready to run the character using keyboard and gamepad input. Yeah 🙂
D-Pad actions
On Xbox gamepad, D-Pad actually uses an Axis input, which means it requires quite different behavior. D-Pad Up And D-Pad Down are Vertical Axis, where Up is a positive and Down negative value. D-Pad Left and D-Pad right are Horizontal Axis, where Left is negative and Right positive value.
To set it right we need another custom igniter that also can be found on Games Creator Hub
Attack input
One Comment
Great content! Keep up the good work!