-
Notifications
You must be signed in to change notification settings - Fork 33
GetDPadUp
static bool GetDPadUp(XboxDPad padDirection);
static bool GetDPadUp(XboxDPad padDirection, XboxController controller);
GetDPadUp()
returns true
the moment the specified D-Pad direction was released. The D-Pad had to be pressed down prior, and then released. It will return false any frame after the moment the direction was released. This is useful for interacting with menu selection with an Xbox controller, for example.
Be aware that GetDPadUp()
currently doesn't work with wired controllers on Linux. See this merge request for more information.
-
XboxDPad padDirection
: An identifier for the specified D-Pad direction you want to test. Please refer to XboxDPad. -
XboxController controller
: An identifier for the specific controller on which to test the D-Pad. If this parameter isn't provided, all connected controllers will be tested for the specified D-Pad direction. It is recommended to omit this parameter if you are making a single player game. Please refer to XboxController for all possible controllers.
The example demonstrates the use of GetDPadUp()
if you wanted a particular player to advance one tile right.
using UnityEngine;
using XboxCtrlrInput;
public class PlayerExample : MonoBehavior
{
public XboxController playerNumber = XboxController.First;
public float tileSize = 10.0f;
void Update()
{
if( XCI.GetDPadUp(XboxDPad.Right, playerNumber) )
{
// Walk right
Vector3 newPosition = transform.position;
float newPos = newPosition.x + tileSize;
newPosition = new Vector3(newPos, transform.position.y, transform.position.z);
transform.position = newPosition;
}
}
}