Forum rules - please read before posting.

Rewired AC Integration Script

Hello, just wanted to share a script to connect Rewired to AC. I based it on Tony Li's from pixel crushers, but it has all the delegates, except the recent new mouse types (which you can add if you feel the need). Anyways, It's worked perfectly for me, so I though it may help someone.


Just attach it to any active object in the hierarchy (personally I put it on the persistent engine or the gameEngine instance, but whatever you know will always be loaded is good.

PS: Weird, I posted this same script on the Technical Q and A section, but here it told me it was too long? There's got to be an issue there.
«1

Comments

  • Thanks! I was considering using Rewired to do my controller setup, so this will be useful.
  • Thank you Alverik, very useful. I'll be trying this soon! :)
  • Hi Alverik and Chris,

    I trying your script in a new project with AC + Rewired. I configured a :

    * 3D AC Game
    * Movement Method: Point and Click 
    * Input Method: Mouse and Keyboard

    The scene is a basic capsule over a plane workig fine with basic AC and then changed to use Rewired as input control

    I attach Alverik script to "Game Engine" object in game and configured a rewired editor like the one in Quick start here (http://guavaman.com/projects/rewired/docs/QuickStart.html)

    But I continue with the basic AC input control. As I has a keyboard, mouse and joystick mapping, I should be able to use keyboard keys to move the cursor (I expect), or I'm missing something?

    I tried as well to change delegates values in order to see what happen and I continue be able to use mouse to move the capusule in the plane with point and click...so I suppose I'm still using default AC input control.

    Do you see something I forgot in my setup? something wrong?

    Hope you could let me know if you find something.
  • edited July 2016
    Ummm, to be honest I have only used this for Direct control, but as you still setup some actions for the mouse (for menus) I don't see why it would not work. Well, In fact I do remember having similar problems, with unresponsiveness, at first, which were more of a "setup" issue.

    First, If you already have unity inputs setup, delete them, if I remember well, they do get in the way. You want to make sure only Rewired is sending input. (EDIT: But you may need to keep the inputs used by the event system's -like, submit-, but I may be wrong -I set up my rewired a long time ago-, Just in case make sure you are using the Rewired event system, because the native event systems will go nuts if the related unity inputs are missing).

    Also, make sure your actions are correctly setup (they need to have the exact same names as the AC inputs listed under the AC's Settings Manager) and, if needed, delete the "save game" cache which the rewired input manager creates. There was a time when I was changing my inputs and it just didn't seem to update in-game, but it was simply because rewired was still using the "cached" input settings from a previous "save".

    Also, to be on the safe side, attach the script to the "Persistent Engine" prefab, in the AC prefabs folder. I usually attach my scripts to that one. If I remember well, the original code excerpt from Tony Li (which I used as a base), stated the script could be anywhere, but put it in the Persistent Engine just in case.

    EDIT: 

    PS: About "using the keyboard keys to move the cursor", I think that would depend on how you setup your actions. I'm not 100% sure, as I'm not close to my development PC to verify, but I recall AC does differentiate between "regular movement Axes", and "Mouse axes for menus" (although that may be because I use Direct: Keyboard or Controller). Still, I remember well that moving my character with WASD didn't move my pointer at all, because the mouse pointer uses a different input axis. If you wanted the WASD to move the pointer you would need to create the actions and assign them the proper inputs in the rewired manager.

    EDIT 2: Once you have deleted all the standard inputs, you'll know if Rewired is working or not (or if you have set it up wrong). If you've made a mistake in the setup, AC will start telling you some Inputs are not setup. If you don't get any warnings then it' probably working fine. If all's good. you'll just need to set it up differently to "move" the cursor with the keyboard.
  • Hi Alverik,

    lots of useful info here. Many Thanks for the time you take to expose all this. I think you give some clues! :)

    Btw, I get a key to work, and I'll be working from that point and with your info to see what's going wrong.

    I ask in the Rewired forum for official support and Rewired's developer said about official integration in AC providing the asset to Chris. I think This would be great since Rewired is a becoming a defacto standard in unity user input remapping and AC will benefit a lot from an official integration.

    More over I want my game could be controled by touch on mobile devices, mouse/keyboard on PC/Mac and so on...and I think AC has a limitation here by default since only let you choose between Touch or Mouse/keyboard, but no both at the same time.

    Hope Chris could say something about this. 
  • Why would you want both at the same time?  You wouldn't use Touch when playing on PC, and you wouldn't use a mouse when playing on a mobile.  You can, of course, change the input method through script whenever you want - just right-click on the label of any field in the Settings Manager to bring up an API reference to manipulate that field (v1.52+).
  • Hi Chris, 

    so If I test on PC I want to use mouse/keyboard, but If I test on iOS or Android I want to use Touch. You propose I have a Script that check the runtime device and change "AC.KickStarter.settingsManager.inputMethod"... that would be the recommended way to go?

    (I could use this in the mean while,  although I think Rewired will be the perfect end solution)

    Thanks for your response and sugestion 
  • I think Carlos meant he wants to use touch for mobiles, and mouse and keyboard for PC and mac,without switching control schemes. But do be mindful, Carlos, exactly because using rewired isn't going to change your control scheme in AC. It'll simply allow your current control scheme (in this case, mouse and keyboard, I guess?) to be used by any other inputs, like touch or joystick. But actually changing the control scheme in AC will give you different features/options specific for the intended devices. Which in some cases, might be what you want.

    Still, I got to be honest and say I've never used rewired for mobile, so I really can't give you any pointers on how to set it up for that. I think, It'll probably be a better idea if you ask about how to properly setup actions for mobile in the rewired forums.
  • Hi Alverik, 

    I already follow a tutorial and set up another test project that use Apex Path with Rewired and use mouse, keyboard and touch. For Touch, I had to copy the provided example an adapt it to get it working, but after that I was getting all kind of control without any configuration, what is very cool since I could test on PC or mobile without problem.

    Now I want to make AC the core and integrate Rewired, Apex Path, and Third Person Controller Template (Invector), since is my dreamed core system.
  • edited July 2016
    Wow, that sounds like a golden combination! AC + Invector + Rewired was already one of my desires, I've also just started to check Apex Path (because I've gotten interested in DunGen for procedural levels) and I must say it sounds really good. But for now I have to wait for invector to do the integration with AC, and I'm unsure how to integrate Apex Path into AC. 

    Anyway, if you  find out anything, I'd be glad if you shared ;)
  • Hi Alverik,

    Apex Path is for me the best in Path Finding. Is very well planned, and easy to customize. I hope to be able to make it work with AC. If I get it, I'll make you know! :)
  • Tried to download script and virus software warned it has virus.  Not sure if its true but you may want to check,
  • Try this page from the AC wiki, @dasjlm.
  • edited September 2017
    @dasjlm Sorry, at that time I was using regular old file upload sites, since they are free they tend to post plenty adds and stuff. People not used to that will sometimes click an add by mistake (since some put a giant Download word on them...). Anyway, as Chris mentioned, this script is already posted up in the AC Wikia (you can find a few interesting stuff in there if you take a look :) ).
  • Hi!

    I've used the provided Code and set up the Actions as best as I could. I've added all Defined Inputs preset in Adventure Creator. When I start the game, the Menus work fine, I can scroll between Items with both the DPad and the Joysticks (I'm using a PS4 Controller) and select things (with the X Button). But when I get to Gameplay my Player won't move nor will the Camera. 

    I'm still a beginner at this :( does anyone know what actions to add in the Rewired-Manager so that the Left joystick moves the Player and the right Joystick moves the Camera? 
  • edited September 2017
    Uhh... I haven't used rewired in ages (been working in a VR project for a long while now). But, I think you had to make sure the actions had the same names as the inputs requested by AC in the Settings Manager. Like it says in the wiki, make sure the are no Unity inputs in the Unity Input manager (mouse ones are ok I think) Then make sure your actions are properly configured, for which I would recommend looking at the Rewired manual. If I can I'll try to open one of my old projects to check, though not sure I still have it...
  • edited September 2017
    Also, make sure that you really are back in gameplay by checking List active ActionLists in Game window? at the bottom of the Settings Manager - that will show the current game state in the top-right corner.
  • edited August 2018
    Thread Necromacy!

    Hey all - I'm adding in gamepad controller support as a patch into Arkhangel and am currently getting Rewired all setup.  Almost everything is in and working as expected (might need to do something fancy for some menus that are not paused).

    One thing I'm concerned about: Saved Games.  

    I loaded several of my saved games and the mouse cursor is locked to the center of the screen and controller input isn't working.  This is working fine if I load the scene fresh, though.  Is there a way to flush/reset the user's input settings and use Rewired on a game load?  I just don't want to tell my users that they'd have to start the game over with an upcoming patch just to get controller support.

    Thank you for any insight!

    EDIT: This seems to be a problem for old AND new saved games (saves that have taken place after I implemented Rewired)...so it looks like I need a little direction to make Rewired Save/Load safe for AC...Any pointers?
  • edited August 2018
    Actually - I seemed to have solved this by moving Alverik's script from PersistentEngine over to GameEngine.
  • Alright - coming back to this as I am at my wit's end...

    I have in-game working great with ReWired.  My main menu is my problem.  I've created a Unity UI and have switched over to using that.  I've followed the Unity UI tutorial and this thread.  I am able to get navigation to work with mouse but controller isn't working much at all.  The only time I can get the first button to highlight on start up is if I have the Unity UI prefab in the scene itself (and not as a prefab) and pull the first button into the EventSystem "First Selected" field.  That lets me scroll but when I press Submit, the button just flashes and doesn't go to the appropriate sub-menu that I have setup in the Unity UI menu (this does work if I use the mouse).  I've tried associating the button via the prefab, the in-scene object, etc...Nothing seems to work.  

    In the Unity UI, I've tried setting up the First Selected as First Visible and have typed in both the menu element name and the prefab name to no avail.

    Any ideas?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.