Unity Community


Page 1 of 12 12311 ... LastLast
Results 1 to 20 of 237

Thread: Wiimote Plugin


  1. Location
    San Francisco, CA
    Posts
    901

    Wiimote Plugin

    Recently someone emailed me (can't remember who, please get in touch) and asked about the Wiimote plugin I mentioned a few months back. The release of Unity 2.0 inspired me to spend some time cleaning it up.

    The screen shot is sort of bland, but trust me, the cube is roughly matching the orientation of the wiimote in my hand:



    Here's how it works. Since Unity has no mechanism for a plugin to send events back into the engine (I really, really thought, based on zero evidence, that Unity 2.0 would support some kind of callbacks) your code has to poll the wiimote on very update. It looks like this:

    Code:  
    1.     void Start () {
    2.         wiimote_start();
    3.     }
    4.  
    5.     void OnApplicationQuit() {
    6.         wiimote_stop();
    7.     }
    8.  
    9.     void Update () {
    10.         int c = wiimote_count();
    11.         if (c>0) {
    12.             display = "";
    13.             for (int i=0; i<=c; i++) {
    14.                 int x = wiimote_getAccX(i);
    15.                 int y = wiimote_getAccY(i);
    16.                 int z = wiimote_getAccZ(i);
    17.                 float roll = Mathf.Round(wiimote_getRoll(i));
    18.                 float p = Mathf.Round(wiimote_getPitch(i));
    19.                 display += "Wiimote " + i + " accX: " + x + " accY: " + y + " accZ: " + z + " roll: " + roll + " pitch: " + p + "\n";
    20.             }
    21.         }
    22.     }

    Although it's not shown here, there is support for the Nunchuck and the IR sensor bar. The plugin is based on DarwiinRemote (on sourceforge) with some modifications to support multiple wiimotes, the event polling (rather than callbacks), and a few other tweaks here and there.

    Plenty left to do (the phantom third Wiimote is a mystery I need to track down) but hey, it's working.

  2. Administrator
    Location
    Copenhagen
    Posts
    1,586
    That is so cool!
    Mathematicians that only do calculations that we already know about and are comfortable with? They're called accountants, and they have no friends.


  3. Location
    Montpellier, France
    Posts
    390
    Where can we get this plugin?
    We just bought a Wii with 2 motes (not moths, mind you, those are a lot cheaper), I'd sure like to get a kick out of it while we're waiting for the SDK.
    Benoit FOULETIER - C# programmer
    Swing Swing Submarine - Seasons after Fall


  4. Location
    Indianapolis, USA
    Posts
    1,115
    So, are we (Unity developers) really going to have the ability to compile for the Wii someday?

  5. Unity Graphics Developer

    Location
    Unity Technologies, basement
    Posts
    3,974
    bliprob's wiimote integration into Unity is completely unrelated to Unity's Wii port that we do. If you want the actual "build for Wii" option, ask David at david@unity3d.com


  6. Location
    Indianapolis, USA
    Posts
    1,115
    I didn't think this Wiimote integration was related to to the official Unity port, but it did make me wonder how that port was going and if/when it is going to happen.


  7. Location
    San Francisco, CA
    Posts
    901
    This plugin is not related to the Unity for Wii system. I don't work for UT and I don't have the Unity Wii engine. I have spoken to David about Unity for the Wii, and it sounds great. The reason I wrote the plugin was so that I could prototype some Wii game ideas, and get funding to purchase the engine.

    In fact, I integrated the Wiimote with an engine once before -- TGE -- and the frustrations we experienced with TGE is what led to our switch to Unity. (You can download the TGE with Wiimote stuff from my blog, http://robterrell.com/ -- scroll down past the baby pictures.)

    The idea was that, once we had the game playing to our satisfaction, then we'd drop the bucks on the Unity Wii engine, either as a capex item that we'd just man up and pay, or through an outside investment. The Wii engine has a substantial additional cost (although not unreasonable, if you price out other console engines). But since then, our company received an infusion of capital (yay!) to focus on non-Wii things (boo!), so this code has sat on the shelf.

    I'll try to put the plugin on the wiki next week. I need to fix the issues with wiimote enumeration that led to the phantom extra controller. But I'll put a binary of the test app online later today, so you can try it out.

    Also, I found a Wiimote model and dropped it into the project. Here's a screenshot and a video.



    Lousy screen capture video: http://robterrell.com/WiimoteUnity.mp4


  8. Location
    Toronto, Canada
    Posts
    145
    Awesome!!! If I were making a FPS, would it be possible to use the wiimote for navigation?


  9. Location
    sydney, australia
    Posts
    136
    That is sweeeeeet

    JW


  10. Location
    Maryland, USA
    Posts
    359
    Good to hear you have turned away from the "dark side."
    Tom


  11. Location
    Cmune HQ
    Posts
    719
    Is the external plugin complied only to a .bundle - or is there a .dll for Windows too?

    Thx
    Shaun


  12. Location
    San Francisco, CA
    Posts
    901
    Quote Originally Posted by JP
    Awesome!!! If I were making a FPS, would it be possible to use the wiimote for navigation?
    Definitely. Last night I added basic Wiimote support to the FPS tutorial. The wiimote does mouselook (IR mode). It's little too sensitive to use, so I'm going to try and make it more playable today. Also I'd like to add nunchuck support for moving.

  13. Unity Product Evangelist
    Location
    San Francisco CA USA
    Posts
    6,186
    Great googley moogley that's cool Rob, nice work!
    Tom Higgins - Product Evangelist at Unity Technologies ApS
    unity3d.com | answers | blogs | feedback


  14. Location
    San Francisco, CA
    Posts
    901
    Ok, wiimote IR and nunchuck support has been added to the fps tutorial. You can run through the level using the nunchuck joystick for movement (i.e. replaces / augments the WASD keys) and using the Wiimote for mouselook/aiming.

    I can make a binary build if anyone wants to try it. You'll need a wiimote and IR bar at least.


  15. Location
    Minnesota, USA
    Posts
    1,713
    Quote Originally Posted by bliprob
    I can make a binary build if anyone wants to try it. You'll need a wiimote and IR bar at least.
    Uhm, triple yes I'd like to try it?

    Cheers,
    -Jon

  16. Unity Product Evangelist
    Location
    San Francisco CA USA
    Posts
    6,186
    Tom Higgins - Product Evangelist at Unity Technologies ApS
    unity3d.com | answers | blogs | feedback


  17. Location
    Vamdrup, Denmark
    Posts
    108
    miiiiiiiiii too


  18. Location
    Seattle, WA, USA
    Posts
    609
    I'd like to try as well


  19. Location
    San Francisco, CA
    Posts
    901
    OK, I'll try to make a public build tonight before I lose Unity to Leopard. I just need to add some basic instructions at the start. Also, I can't recall if I made the plugin as a Universal Binary, so I need to check that.

    Tom: you took a Wiimote with you to Paris???


  20. Location
    San Francisco, CA
    Posts
    901
    Ok, sorry about the low quality of these releases, but I rushed to get them done before installing Leopard (I need to test & debug my other software on the new cat). These files are uploading now.


    Uniwii: http://robterrell.com/uniwii.zip

    Connect a Wiimote (make sure your Mac bluetooth is turned on, but no need to pair the Wiimote) and watch the on-screen Wiimote twist and turn as you move the real Wiimote. If you have an IR sensor bar, you'll see the pointer position on screen.


    FPS Tutorial with Wiimote: http://robterrell.com/fps_wiimote.app.zip

    Requires IR mode, so you need a Wii sensor bar (I use a Nyko $20 sensor bar on my Mac, or make your own as shown on my blog, http://robterrell.com). The pointer controls mouselook; the "A" button is jump, the "B" button is fire current weapon. Buttons 1 and 2 change the selected weapon. If you have a nunchuck, you can use the joystick to move around; if not, use WASD.

    Note: If you are using a Nyko or homemade sensor bar, you need to make sure you stand back the proper distance from your computer. You can't sit in front of the screen and have it work: the wiimote can't see enough IR leds.

Page 1 of 12 12311 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •