So you want controller input available for your game, but setting up the controls for every different controller across Windows, Mac, or Linux seems like a drag!

Rewired is an awesome asset for handling all the different controller inputs, but for anyone unfamiliar with how ORK handles custom input, it might be a little tricky to integrate it. Basically you need to create a static function with whatever Input manager you're using that returns a float or bool when a player presses a button/moves a joystick. Here's a quick and simple tutorial to get you started!

1. Buy Rewired at the Unity asset store. It's 45 dollars, but worth it for avoiding the stress of figuring all this out yourself. You could buy a cheaper Input manager and hopefully this might still help you understand the core concept of ORK's custom input, but this guide is specific to Rewired. Anyway, here's a link: https://www.assetstore.unity3d.com/en/#!/content/21676

2. Follow this guide from the Rewired documentation page right up until you get to the script part:
http://guavaman.com/projects/rewired/docs/QuickStart.html

3. You're NOT gonna use that script. You're going to use this script that works with ORK's custom input. Attach this to an object that doesn't get destroyed on loading the next scene. I attached mine to the Rewired Input Manager:

using UnityEngine;
using System.Collections;
using Rewired;


public class gamepadControls : MonoBehaviour
{

// Static members
private static Player player;

//static function that returns float based on axis position
public static float GetAxis(string actionName)
{
if (player == null) return 0f;
return player.GetAxis(actionName);
}
//static function that returns bool value of true as long as button is held
public static bool GetButton(string actionName)
{
if (player == null) return false;
return player.GetButton(actionName);
}
//static function that returns bool value of true only once on first frame of button press
public static bool GetButtonDown(string actionName)
{
if (player == null) return false;
return player.GetButtonDown(actionName);
}

// Instance members
public int rewiredPlayerId = 0;

void Awake()
{
player = Rewired.ReInput.players.GetPlayer(rewiredPlayerId);
}
}


4. You're going to use the script's class name in the class slot, the function name in either the axis or button function slot (axis applies to directional buttons/sticks and button applies to...buttons), and then add a parameter with whatever you called the input in the Rewired setup. For example, I named my Horizontal axis input....Horizontal. Here's a picture.
image

and that's it. The buttons should now be just as functional as if they were using ORK input keys or the Unity Input Manager, and now they will work with most any controller on Windows, Mac, or Linux.

...well except the PS3's Dualshock 3. That one requires Xbox emulation. Stupid PS3. >_<


EXTRA TIP: Don't forget to set both the gravity and sensitivity in the Rewired setup window (under input behaviors) to a high number like 1000 if you want really responsive controls!

Anyway, I hope this helps some of you!
Post edited by braytendo on
  • Great work! Been meaning to give Rewired a try. This motivates me to do so sooner than later.
  • It's definitely worth it. I've tried a couple controller plugins, and this is by far the quickest to use, most frequently updated, and supports the most gamepads. I kinda wish there was a cheaper version without all the multiplayer support since I'm not making a multiplayer game...but who knows, maybe someday.
  • Just revisiting this thread a couple months later.

    Rewired is awesome. And this little script is all you need to get it working with ORK.

    I've needed to change a few input settings on my ORK - Opsive TPC integration package and I'm REALLY missing Rewired there.

    So thanks for the script, and for prompting me to try Rewired sooner rather than later.
  • Sure thing! Glad I could help :)
  • Thank you, Braytendo. I was looking for a simple way to get rewired plugged into ORK.
  • Sorry to necro an old post, but I have to give props where they're due. @braytendo You are amazing. 5 years later this still works like a charm.
  • It's still the script I'm using 5 years later as well!

    Cheers to anyone else that's been working on a game that long lol.
Sign In or Register to comment.