-
Notifications
You must be signed in to change notification settings - Fork 33
GetDPadDown
static bool GetDPadDown(XboxDPad padDirection);
static bool GetDPadDown(XboxDPad padDirection, XboxController controller);
GetDPadDown()
returns true
the single moment the specified D-Pad direction was pressed down. If the specified direction was pressed down after that moment, it will return false
. It will return true
again if the direction was released and then pressed down again. This is useful if you want the player to press down a specific direction, but didn't intend for the button to be held down.
Be aware that GetDPadDown()
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 GetDPadDown()
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.GetDPadDown(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;
}
}
}