Gamepad

Gamepad, joystick and game controllers can be used in your game. XBox, Playstation and generic controllers are supported.

This feature can be activated by adding the Gamepad extension to your project. You will then be able to use conditions and expressions to check if a gamepad is connected, if a button is pressed, released or if a stick is pushed.

See it in action! 🎮
Open this example online.

Install the Gamepad extension

Start by searching for new extensions in the Project Manager:

Select the Gamepad (controllers) extension and choose Install in project:

You can now use the Gamepad conditions in your game. You'll find them in the “Other conditions” list, inside the “Gamepad (controllers)” category:

Detect connected gamepads

Each gamepad connected to the computer or phone is numbered from 1 to 4:

  • If your game is single player, you'll usually always use condition for the Gamepad 1.
  • If your game is multi player, it's a good idea to use the Gamepad connected condition to check which gamepads are connected. You could store in a variable the gamepad number associated to a player. You can also force the first player to use the Gamepad 1, and the other player to use Gamepad 2.

Handle pressed buttons

Detecting pressed buttons can be done with the Gamepad button pressed (or released) condition. When using the condition, read the description to see all button names that are supported

Support multiple types of controllers

Playstation and Xbox controllers have different names for their buttons.

You can easily support both controllers, and other types too, in your game: use an OR condition and add the condition for each type of controller inside the OR block.

Handle sticks

Sticks can be pushed in different directions, usually to move the player. Using the expression Gamepads::AxisValue, you can get a number representing “how much” the stick is pushed in a direction.

You can then use it to set a force on an object (or anything else that you want to impact in your game):

Vibrate a gamepad

Use the action Gamepad vibration to make a gamepad to vibrate.