Gamepad Input
Roblox accepts input from USB gamepads such as Xbox and Playstation controllers. A game can support up to eight local controllers per client.
Detecting Gamepads
You can detect whether a player’s device currently has a gamepad active using the UserInputService/GamepadEnabled|UserInputService.GamepadEnabled property. Note that this property merely shows whether or not any gamepads are connected, not how many are plugged in or which slots they’re in.
Since up to eight gamepads can be connected to a client at once, it’s important to know which are active. One method is to listen to the UserInputService/GamepadConnected|GamepadConnected and UserInputService/GamepadDisconnected|GamepadDisconnected events which will fire when a device is enabled or disabled respectively. Both will pass a Enum/UserInputType enum to the connected function indicating which gamepad caused the event (in most cases it will be Enum.UserInputType.Gamepad1 but if your game supports local multiplayer, you should confirm this).
You can also actively query whether a particular controller is connected using the UserInputService/GetGamepadConnected|UserInputService:GetGamepadConnected() function. This takes a Enum/UserInputType enum as an argument and only accepts values of Enum.UserInputType.Gamepad1 through Enum.UserInputType.Gamepad8 .
Getting Input
There are three ways to get input from a gamepad:
- Use ContextActionService if you plan to bind custom game controls to both gamepads and other input sources like keyboards or mobile touch controls.
- Listen for gamepad events directly using UserInputService .
- Query the state of a gamepad’s input with the UserInputService/GetGamepadState|UserInputService:GetGamepadState() function.
ContextActionService
ContextActionService is especially useful for binding controls to both gamepads and other input sources. For example, if you want to bind a custom “open spell book” action to the right trigger (R2) on a gamepad and the B key on a keyboard, ContextActionService can handle both cases in one function:
UserInputService
When detecting gamepad events with UserInputService , all of the controls will fire the UserInputService/InputBegan|InputBegan and UserInputService/InputEnded|InputEnded events. In the handling function, the InputObject/UserInputType property indicates which gamepad fired the event and InputObject/KeyCode indicates the specific button or stick that fired it.
Most gamepads also support analog controls. To detect input from these, use the UserInputService/InputChanged|InputChanged event and detect the position of the input’s axis via InputObject/Position . The thumbstick’s position will always be on the X and Y axes between the values of -1 and 1, while the trigger buttons will only have values between 0 and 1 on the Z axis (0 at its starting position; 1 when fully pressed).
Gamepad Input State
The state of all the buttons and sticks on a gamepad can be detected at any time with the UserInputService/GetGamepadState|UserInputService:GetGamepadState() function. This is useful if you need to detect gamepad input when a non-controller event occurs. For example, the following code detects when a character’s left foot touches something while the player is holding down the right trigger:
Supported Inputs
Not all gamepads have the same number or types of inputs, so it’s important to check which inputs a connected gamepad has. You can do so with the UserInputService/GetSupportedGamepadKeyCodes|UserInputService:GetSupportedGamepadKeyCodes() function which takes a Enum/UserInputType enum as an argument and returns a table with a list of all available inputs for the specified controller.
Best Practices
As with any method of user input, it’s best to create some consistency across different games and applications. This helps players immediately feel familiar and comfortable with your control scheme. Here are some suggested practices when implementing gamepad controls:
- If you implement any user prompts or GUI selection, the A button should be “accept.”
- For any GUI or any state that is modal, the B button should be “cancel.”
- On-screen hints for which buttons do what are helpful, especially for a complicated GUI like an inventory system, upgrade system, etc.
- Character movement should be tied to the left thumbstick.
- Camera movement should be tied to the right thumbstick.
- Primary actions usually happen with the right trigger (R2) or the A button.
- Secondary actions usually happen with the left trigger (L2) or the R1 and L1 buttons. If you’re tying a secondary action to a front-face button, X and Y are good choices.
- Allowing players to remap buttons can make your game much more accessible.
Related Articles
Gamepad Haptic Feedback
How this site use cookies
This Platform uses cookies to offer you a better experience, to personalize content, to provide social media features and to analyse the traffic on our site. For further information, including information on how to prevent or manage the use of cookies on this Platform, please refer to our Privacy and Cookie Policy.
Please press Continue to go to:
© 2021 Roblox Corporation. All Rights Reserved.
Источник
Как настроить геймпад для роблокс
Roblox – это невероятная виртуальная вселенная для игр, их создания и воплощения всех ваших фантазий. Присоединяйтесь к миллионам игроков и погрузитесь в невероятное многообразие миров, созданных этим сообществом!
Уже есть учетная запись? Войдите в свою учетную запись Roblox и наслаждайтесь играми!
МИЛЛИОНЫ УДИВИТЕЛЬНЫХ МИРОВ
Хотите отправиться в эпическое ролевое приключение? Или сразиться с противниками со всего мира? А может, вам хочется просто расслабиться и пообщаться с друзьями? Количество разнообразных миров, созданных пользователями, постоянно растет — а значит, вы сможете открывать для себя что-то новое каждый день.
ИГРАЙТЕ ГДЕ УГОДНО И КОГДА УГОДНО
Играть можно даже в дороге. Roblox обеспечивает полную межплатформенную поддержку: вы можете играть с друзьями и миллионами других игроков, использующих компьютеры, мобильные устройства, Xbox One и гарнитуры виртуальной реальности.
ВСЕ БУДЕТ ТАК, КАК ВЫ ЗАХОТИТЕ
Дайте волю своему воображению и проявите себя во всей красе! Сделайте свой аватар уникальным с помощью разнообразных головных уборов, предметов одежды и снаряжения, черт лица и других элементов. Благодаря огромному каталогу предметов вы сможете создать по-настоящему неповторимый облик.
ОБЩАЙТЕСЬ С ДРУЗЬЯМИ
Общайтесь с друзьями со всего мира с помощью чата, личных сообщений и групп!
Особенности: 3D, Online
Русский интерфейс: Нет
Системные требования: 5.0+
С запросами на обновление игры обращайтесь в тему Обновите игру!
Версия: 2.444.410148 Roblox (Razalina)
Версия: 2.427.399257 (717) Roblox (Belkodil)
Версия: 2.421.385673 Roblox (qqweezi)
Версия: 2.418.380321 Roblox (qqweezi)
Версия: 2.409.358770 Обновление (arseny unknown)
Версия: 2.403.344044 GP: arm7a (hackdog)
Версия: 2.396.327208 ROBLOX (andreyk666)
Версия: 2.388.307917 Оригинал и APILMod версии (ANDREYMASTER09)
Версия: 2.388.307917 Новая версия ROBLOX (artem90y)
Версия: 2.374.282978 ROBLOX (ANDREYMASTER09)
Версия: 2.372.278233 ROBLOX [+ Mod] (ANDREYMASTER09)
Версия: 2.368.271958 ROBLOX [+ Mod] (ANDREYMASTER09)
Версия: 2.366.266498 ROBLOX [+ Mod] (ANDREYMASTER09)
Версия: 2.362.255825 ROBLOX (ANDREYMASTER09)
Версия: 2.342.212340 ROBLOX (ANDREYMASTER09)
Версия: 2.341.208519 ROBLOX (ANDREYMASTER09)
Версия: 2.323.178571 Roblox_com.roblox.client.apk ( 64,24 МБ )
Сообщение отредактировал DreamSpL1nteR — 15.10.21, 21:50
Источник