Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Saturday, March 27, 2010

Controlling Unity3D with an Android phone

In my previous post I turned my Android G1 into a game controller for an Adobe Air desktop app. The same thing can be done with a Unity file. Although I didn't have much time to make something really nice, I've quickly put together a short video, which demonstrates that Unity also supports UDP. Again, I've used RemoteDroid to send data to my computer over its wireless network. You can read more about the how in the previous post.

I'm not sure who made the 3d jet model, but I downloaded it here.

Thursday, February 25, 2010

Remotely controlling a desktop AIR app with an Android phone

AIR 2.0 has support for UDP sockets, which allows you to send and receive messages using the Universal Datagram Protocol. This means that you can communicate with other applications without the need for an extra server.

I used RemoteDroid for this demo, which is an Android app that turns your Android phone into a remote control, using your own wireless network. Originally, the app gives remote access to native applications on your computer and simulates the mouse - moving it and pressing left and right buttons - but you also need to download a server on your computer to make that work.

However, since AIR 2.0 supports UDP, you don't need an extra server to make your Android phone communicate with an AIR app. In this video, I made the AIR app listen for UDP messages sent by the Android app, to control a paperplane in a Papervision3D scene. So basically, you can turn your Android phone into a game controller.

RemoteDroid has just been open sourced, which gave me a chance to take a look at the source code of the Android app. I added the accelerometer data of the phone to it (locally, I didn't contact the owner of the project yet), and in the video you can see how I:
- control the speed of the paperplane by pitching the phone
- steer the paperplane by rolling the phone,
- zoom in and out by pressing the left 'button' on the phone's touch screen
- change the camera mode to a random perspective by pressing the right 'button' on the touch screen
- change the camera perspective to the Third Person, First Person and default perspective by pressing the 1, 2 and 3 keyboard keys respectively.



The Papervision3D scene in the video stems from chapter 6 of the Papervision3D Essentials book.

Of course there are other apps than AIR that support UDP. For instance, I also managed to control a Unity file this way, so another video will follow soon.