Wii Remote + IR Sensor Bar
by Rob Terrell · 12/17/2006 (6:49 pm) · 12 comments
The Wiimote is really working well in TGE now. Here's a shot of it controlling the default demo mission, with the "killer kork" resource added in to make it interesting. I mapped the Wiimote "A" button to move forward, and the "B" trigger button to fire.

Here's the screen capture video. YouTube link for the bandwidth conscious, and [url="http://stinkbot.com/Wiimote+IR.mov"]QuickTime[/url] for those who don't care what my ISP thinks about me.
To make this work, I put together a homemade sensor bar with under $10 of parts from Radio Shack and crap lying around the room:

If you want to make your own, I run through the how-to (basically, LEDs, wires, batteries) on [url="http://robterrell.com/archives/13"]my personal blog[/url].
The "sensor bar" isn't actually a sensor -- it provides an absolute point of reference. Without the sensor bar, the Wii remote can only detect the controller's tilt along three axes. (If you looked closely at my earlier video, you'll see that, to control the game, I was tilting the controller each time I wanted to go left or right.) This works and is fun, but it makes aiming very hard.
So, with a sensor bar above the screen, we can actually get absolute X and Y values. The controller gives us a floating point value between 1.0 and -1.0 that we translate into an on-screen coordinate. Point to a spot on the screen, and the mouse pointer jumps to it.
Also, a change from before. I mapped the "A" button to mouse button 3, and the "B" trigger button to mouse button 4. This way the Wii buttons can be more independently mapped from your mouse controls.
So next, I think, is to automatically switch to accelerometer mode when the IR link is down (i.e. the controller has moved too close to the LEDs, or too far to one side, and can't see both). Also, there's a way to run in a single-LED mode, which would probably be good enough for this use. That would let me get closer to the screen (in the video you see me back off).
I've also added rumble support, but I need to expose that to scripting. Maybe later tonight.
I will try to clean this up and make a resource. If anyone is interested in a binary release, let me know in the comments.

Here's the screen capture video. YouTube link for the bandwidth conscious, and [url="http://stinkbot.com/Wiimote+IR.mov"]QuickTime[/url] for those who don't care what my ISP thinks about me.
To make this work, I put together a homemade sensor bar with under $10 of parts from Radio Shack and crap lying around the room:

If you want to make your own, I run through the how-to (basically, LEDs, wires, batteries) on [url="http://robterrell.com/archives/13"]my personal blog[/url].
The "sensor bar" isn't actually a sensor -- it provides an absolute point of reference. Without the sensor bar, the Wii remote can only detect the controller's tilt along three axes. (If you looked closely at my earlier video, you'll see that, to control the game, I was tilting the controller each time I wanted to go left or right.) This works and is fun, but it makes aiming very hard.
So, with a sensor bar above the screen, we can actually get absolute X and Y values. The controller gives us a floating point value between 1.0 and -1.0 that we translate into an on-screen coordinate. Point to a spot on the screen, and the mouse pointer jumps to it.
Also, a change from before. I mapped the "A" button to mouse button 3, and the "B" trigger button to mouse button 4. This way the Wii buttons can be more independently mapped from your mouse controls.
So next, I think, is to automatically switch to accelerometer mode when the IR link is down (i.e. the controller has moved too close to the LEDs, or too far to one side, and can't see both). Also, there's a way to run in a single-LED mode, which would probably be good enough for this use. That would let me get closer to the screen (in the video you see me back off).
I've also added rumble support, but I need to expose that to scripting. Maybe later tonight.
I will try to clean this up and make a resource. If anyone is interested in a binary release, let me know in the comments.
About the author
Recent Blogs
• iPhone games!• TGWii Code
• Wii Remote Beta Binary
• Wii Remote Control in TGE is Working
#2
Very cool work!
12/17/2006 (7:51 pm)
Sir.. you do know you should have your wrist strap on your wrist while playing your Wii.... for shame!Very cool work!
#3
I must say, a binary would be super cool. Here's the quicktime link again.
stinkbot.com/Wiimote+IR.mov
12/17/2006 (8:07 pm)
Excellent work!I must say, a binary would be super cool. Here's the quicktime link again.
stinkbot.com/Wiimote+IR.mov
#4
12/17/2006 (10:23 pm)
...WOW! Well done.
#5
12/18/2006 (1:37 am)
Very nice work, Rob. :)
#6
12/18/2006 (3:22 am)
I'm looking forward to the resource!
#7
12/18/2006 (10:24 am)
Now that you've had a chance to play with it a little, how viable is the performance to actually run the gamut of input options, and what would be the best use of the controller in the input scheme?
#8
Also, this kind of controller gives lots of options. With the IR turned on, X-Y position can be handled by the pointer, leaving you the tilt axes for other things. If you've played Wii golf, think about how that works. The IR mode is used for positioning the cursor on screen, whereas the accelerometers control the swing of the club. You can both interact with the GUI or swing the club. Think of a sword-fight game (the inevitable jedi game) -- you could position the base of the sword using the IR mode's X-Y coords, and then allow the user to twist the controller to parry. (I guess the best demo I could make would be a light-saber positioning demo.)
Anyway, I doubt that PC gamers will buy Wiimotes. I just wanted to prototype a game idea for the Wii.
12/18/2006 (1:51 pm)
@Dave: it all depends on your game. I think it's working well for starter.fps (although I do want to fine-tune the sensitivity a bit). However, it feels wrong to be sitting at my desk and waving the Wiimote. Also, this kind of controller gives lots of options. With the IR turned on, X-Y position can be handled by the pointer, leaving you the tilt axes for other things. If you've played Wii golf, think about how that works. The IR mode is used for positioning the cursor on screen, whereas the accelerometers control the swing of the club. You can both interact with the GUI or swing the club. Think of a sword-fight game (the inevitable jedi game) -- you could position the base of the sword using the IR mode's X-Y coords, and then allow the user to twist the controller to parry. (I guess the best demo I could make would be a light-saber positioning demo.)
Anyway, I doubt that PC gamers will buy Wiimotes. I just wanted to prototype a game idea for the Wii.
#9
12/18/2006 (1:54 pm)
To me, it's not about whether or not PC gamers will buy wii remotes, because I think if you brought some of that functionality to the PC in a reproducable and afforable way, it just opened the gates on the while interactive physical activity kinda genre onto the PC. Piggybacks quite nicely.
#10
:)
12/18/2006 (1:59 pm)
Glue it to the side of a helmet and you'll have a Eurofighter, F35, Apache controller..:)
#11
12/18/2006 (8:20 pm)
Darn, now that is seriously cool :)
#12
02/25/2007 (8:42 am)
am eagerly waiting for the code 
Torque 3D Owner Aun Taraseina
Can't wait to see this as a resource.