Showing posts with label controller. Show all posts
Showing posts with label controller. Show all posts

Tuesday, May 7, 2013

Xbox Controller Input Wrapper for Unity




After setting up Gamepad input in Unity for around the 5th time, I decided to write a wrapper class to avoid future suffering. The class mimics the Input.GetButton() and Input.GetButtonDown() functions.

I also added a GetState() function, similar to XNA, which returns a snapshot of the controller's state.

Caveats:
  • You will need to replace the InputManager.asset file located in the ProjectSettings folder with the one contained in the package.
  • GetButtonDown() and GetButton() cannot be used to check the up/down/left/right buttons because Unity treats the dpad as an axis.