InputManager nightmare

joaquingrechjoaquingrech Posts: 22Member
Hi
I've downloaded the sdk yesterday. I'll skip the bitching and cursing about the documentation since it's my first post and go to the subject.

I'm trying to get input using the standard way of Unity: Input.GetAxis and so on. I don't want to go around changing all my code just because I've got an OUYA.

So from this forum this is what I've got:
If you want to use the standard Unity input, you have to change OuyaUnityApplication.java... so I did to no avail:
What I did is what I've read
1) Extend UnityPlayerActivity instead of Activity
2) Remove all onCreate except the super.onCreate call
3) Comment out all the input methods

Result:
Crash. The logcat gives this:

D/AndroidRuntime( 2209): Shutting down VM
W/dalvikvm( 2209): threadid=1: thread exiting with uncaught exception (group=0x4
1c43300)
E/AndroidRuntime( 2209): FATAL EXCEPTION: main
E/AndroidRuntime( 2209): java.lang.Error: FATAL EXCEPTION [main]
E/AndroidRuntime( 2209): Unity version     : 4.2.0f2
E/AndroidRuntime( 2209): Device model      : OUYA OUYA Console
E/AndroidRuntime( 2209): Device fingerprint: OUYA/ouya_1_1/ouya_1_1:4.1.2/JZO54L
-OUYA/346:user/test-keys
E/AndroidRuntime( 2209):
E/AndroidRuntime( 2209): Caused by: java.lang.RuntimeException: Unable to resume
 activity {com.bocazas.dogfight/com.bocazas.dogfight.OuyaUnityApplication}: java
.lang.NullPointerException
E/AndroidRuntime( 2209):        at android.app.ActivityThread.performResumeActiv
ity(ActivityThread.java:2575)
E/AndroidRuntime( 2209):        at android.app.ActivityThread.handleResumeActivi
ty(ActivityThread.java:2603)
E/AndroidRuntime( 2209):        at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2089)
E/AndroidRuntime( 2209):        at android.app.ActivityThread.access$600(Activit
yThread.java:130)
E/AndroidRuntime( 2209):        at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1195)
E/AndroidRuntime( 2209):        at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime( 2209):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2209):        at android.app.ActivityThread.main(ActivityThrea
d.java:4745)
E/AndroidRuntime( 2209):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 2209):        at java.lang.reflect.Method.invoke(Method.java:5
11)
E/AndroidRuntime( 2209):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 2209):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:553)
E/AndroidRuntime( 2209):        at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime( 2209): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 2209):        at com.bocazas.dogfight.OuyaUnityApplication.onR
esume(OuyaUnityApplication.java:277)
E/AndroidRuntime( 2209):        at android.app.Instrumentation.callActivityOnRes
ume(Instrumentation.java:1184)
E/AndroidRuntime( 2209):        at android.app.Activity.performResume(Activity.j
ava:5095)
E/AndroidRuntime( 2209):        at android.app.ActivityThread.performResumeActiv
ity(ActivityThread.java:2565)
E/AndroidRuntime( 2209):        ... 12 more


so anyone was able to compile that java file and get regular Unity input without all the fancy OuyaInput classes? It is driving me nuts after 1 hour sleep :(



Comments

  • StoicHamsterStoicHamster Posts: 113Member
    To use the standard Unity Input class all you have to do is import the Ouya Unity plugin (especially the InputManager.asset which defines all the axes and buttons), then make sure to uncheck the UseLegacyInput option on the OuyaGameObject.

    That's all there is to it. Not sure about all the stuff you're talking about. And there shouldn't be any Java changes required. Did you just get the base Java ODK instead of the Unity Ouya C# plugin? The plugin takes care of all that nasty stuff for you.

    You can also use the OuyaExampleCommon script to handle Input as well. It will take care of button mappings for different controllers if you want to support PS3 controllers, for example.
    Jarcas Studios - Check out our latest Ludum Dare game: The Vengeful Baby-Men

    Take some time and learn Designer-Friendly Programming 101.
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    edited July 2013
    Here's the documentation on how to use Unity Input after you've imported Core.

    Post edited by tgraupmann on
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • joaquingrechjoaquingrech Posts: 22Member
    The problem is that documentation is obsolete. How do you import the unity plugin? well, you get the .unitypackage and import it right? nope. If you download the latest version from git, there is no such thing as a unity package. You can't import anything. You need to manually copy over the files if you know what you are doing.

    Secondly, you follow the unity input and it won't work again if you follow the documentation. From what I see, that documentation used to work at some point with previous versions of the plugin but if you are new to the system, you won't be able to even hit step 2 without already finding problems.

    It is easy, just download those packages as if you were a new user who got OUYA today, and Unity today, and try to follow the doc. You'll find it is impossible to do it as documented.



  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Did you click the link, maybe your browser is cached but I updated the docs.

    You open the git checkout as a Unity project and there's export options in the OUYA menu to get the old packages that you're used to.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • Killa_MaakiKilla_Maaki Posts: 504Member
    edited July 2013
    The problem is that documentation is obsolete. How do you import the unity plugin? well, you get the .unitypackage and import it right? nope. If you download the latest version from git, there is no such thing as a unity package. You can't import anything. You need to manually copy over the files if you know what you are doing.

    Secondly, you follow the unity input and it won't work again if you follow the documentation. From what I see, that documentation used to work at some point with previous versions of the plugin but if you are new to the system, you won't be able to even hit step 2 without already finding problems.

    It is easy, just download those packages as if you were a new user who got OUYA today, and Unity today, and try to follow the doc. You'll find it is impossible to do it as documented.

    I followed the docs perfectly just the other day.
    I didn't even check out the GIT repo, just downloaded it as a ZIP and opened the project in Unity. Then, after getting the proper things installed and located (such as JDK and proper platforms of the Android SDK), you can go to the OUYA panel window and hit "Export Core Package".
    Bam. Now you have a UnityPackage.

    To use Unity Input, just uncheck the Use Legacy Input checkbox.
    I've tested it, and it works flawlessly.
    Post edited by Killa_Maaki on
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • StoicHamsterStoicHamster Posts: 113Member
    It is easy, just download those packages as if you were a new user who got OUYA today, and Unity today, and try to follow the doc. You'll find it is impossible to do it as documented.
    If you just got Unity today, you should spend time familiarizing yourself with vanilla Unity on the PC/Mac first before even touching Ouya stuff. I think the Ouya Unity plugin docs assume some familiarity with Unity and you've gotta get the basics before adding the extra complexity of the Ouya layer.

    I'll admit that having to create an extra Unity project just to generate the Unity package needed to import into your actual project is a little odd. Ideally, devs would be able to just download the *.unitypackage file rather than generating it themselves.

    Other than that little weirdness, the plugin has worked great for me. Just like Killa_Maaki said, import the package, uncheck the box. Done!

    Is it a bit confusing? Maybe. Is the documentation perfect? No. Is it impossible? Hardly.
    Jarcas Studios - Check out our latest Ludum Dare game: The Vengeful Baby-Men

    Take some time and learn Designer-Friendly Programming 101.
  • joaquingrechjoaquingrech Posts: 22Member
    edited July 2013
    StoicHamster, I'm beta tester of Unity and Unity dev for over 2 years... so I think I've got some "familiarity". The game I'm trying to port to Ouya is Dogfight, which I made by myself and you can check at www.dogfightplay.com working in multiple platforms. In short. I'm not a newbie.

    Having said that... the Ouya doc for the plugin is not right. I'm one of the few people who actually reads the docs before posting and when installing it for the first time. It mentions numerous files and packages that do not exist on the latest Ouya sdk. It's also a mess in the sense that unless you are a pro dev you have no idea which package you have to install and in which order since it seems the SDK should be installed but in reality you have to install only the unity one.

    Secondly, the unity package besides incomplete documentation, it creates several conflicts if you are using it on an existing project. I would mess up all your manifest, input managers and so on. So you can't use it as a base for anything or just "import package and be happy" either. If you can't import the package but also in no place it explains which files it requires (it does, and they are wrong), then you have to figure it all out by yourself.

    All docs point out on how to create a new project, new game and new whole thing on Ouya but take no consideration that you may already have something done before and you don't want to trash it.

    I'm ok doing most of the work because I'm a regular beta tester, but you can't deny the facts: the documentation is not proper and the average dev would have a hard time using unity to migrate an existing game to ouya.


    Post edited by joaquingrech on
  • joaquingrechjoaquingrech Posts: 22Member
    edited July 2013
    To make things simpler. Do this:
    1) Get any current android game that works on your phone (not ouya project)
    2) Get the SDK or Unity git from Ouya and try to follow the documentation to make your game work on Ouya without messing up your existing project input controllers and all.

    Easier said than done. Maybe it is very simple, but certainly not following the doc.

    Post edited by joaquingrech on
  • joaquingrechjoaquingrech Posts: 22Member
    Lastly, to make things easier for those migrating a project. I think what's needed is a unitypackage with the most basic stuff (even less than core package).

    1) The dll/plugins required to run on Ouya
    2) No inputmanager overwrite, nor inputmanager anything. If you already have a game developed you have your own inputmanager done for pc/mac/xbox/ps3 or whatever. You don't want the Ouya import to break it.
    3) Manifest example file, separated from the import. So you can merge it manually with your existing one.

    Done. If the input is not overwritten, it should autodetect your controller and run the game if it was running fine on an android and gamepad version. You would need to take care of some things but not having to modify your whole input manager structure would save lot of time.
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    When I imported into several existing games, all I needed to do was make a static mapping class.

    Anywhere you coupled your game logic to the input system like:

    Input.GetAxisRaw("FireTheBigLasers")

    you replace with

    YourMappingClass.GetAxisRaw("FireTheBigLasers")

    And in YourMappingClass you have a condition:

    if (axisName == "FireTheBigRedLasers")
    {
       return OuyaExampleCommon.GetAxis(BUTTON_O, Player1);
    }
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • joaquingrechjoaquingrech Posts: 22Member
    tgraupmann the problem is that if you import as regular, it also messes up the input settings on the project. At least it did for me. I already have my own input class full of #if UNITY_OUYA stuff (i've set a define for it), but I still don't get any input.

    I don't know what's the problem but the regular input is just not working.

    Also, I don't want to use OuyaExampleCommon.GetAxis, i want to use Input.GetAxis I saw on your latest git commit that you removed legacy input as an option, and it is something that many of us want. It is very tedious to write Input specific code for ouya when Unity handles it byself for almost any gamepad in the market.


  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Right I want to use OuyaSDK as just a way to get the axis name. And then you use Input.Get* using that axis name in the future.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • joaquingrechjoaquingrech Posts: 22Member
    sorry, i didn't understand the last message :)

    There is no way to get the input directly from unity using Input.Get* without the need of the ouyaexamplecommon class? I've tried removing and recompiling the java classes with not much luck.

  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    The GetButton method needs to be moved to OuyaSDK and changed to return the keycode instead of returning the result of Input.Get*
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • FREEZXXFREEZXX Posts: 12Member
    I was also having many issues with the input trying various ways to work with it because working with the existing input managers that come with the ODK felt very confusing and cluttered.

    Eventually i decided to try out this http://forums.ouya.tv/discussion/1678/new-ouyainput-controller-framework-simple-fast-with-documantation#latest

    Works flawlessly and is very simple and easy to use and works with xbox and ps3 controllers.
    No problems since.
  • joaquingrechjoaquingrech Posts: 22Member
    freezxx for what i've read, the next ouyasdk won't allow that manager to work since it uses legacy calls
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    It'll work, it uses the faster input.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • joaquingrechjoaquingrech Posts: 22Member
    but is it needed? I mean, right now, I removed the whole ouya unity package, installed this input manager from this thread and it works perfect! (something i was not able to achieve with the unity package)
    Of course, i can't submit to ouya because it doesn't use the tv.game and all those namespaces that are required... but it works just fine on my console.
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    There are several input systems available. You can choose whatever works for you.
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
Sign In or Register to comment.