Posts Tagged 'Android'

Unity Android and the Android Market Licensing (LVL) – a cautionary tale…

If you’ve been following this blog then you no doubt know all about my augmented reality game Zombie Room AR. What you may not know is how much of a struggle I’ve had trying to support it. If you look at the demo version in the android market you’ll see a crap  load of 1 star reviews saying the game crashes and that I suck and other idiotic comments. Over the past year I’ve been an Android developer and I know that the Star ratings and comments are on par with youtube comments, so I’ve brushed most of these off…

Unfortunately, the one thing these comments have in common is that they’re right… the game just crashes on a lot of devices… mysterious crashes that leave me scratching my head in wonder. The strangest thing is that when the game crashes, it just sort of exits. Typically when a program crashes on Android you get a box pop up with a “Force Close” or “Report” option. If you click “Report” it sends a stack trace to the developer, which will give him a clue about what the problem is. I never got one stack trace, so I had absolutely nothing to go off of. I have 4 different Android devices I test against I have not ever been able to reproduce this issue. In some cases I’ve had customers reach out to me by email asking what the deal is… and I’ve never had a good answer for it… Until today. Continue reading ‘Unity Android and the Android Market Licensing (LVL) – a cautionary tale…’


Accessing the Android Compass through Unity 3D.

OK, let’s go ahead and get this out of the way. This post is not for beginners or the faint of heart. There is no way to access Android’s Magnetic Field Sensor (aka the compass) directly from Unity, so in order to do that we’re going to have to write a custom plugin. This is not an easy task, and I honestly don’t know how well I can explain it – so… stick with me and hopefully we’ll get through this together. (Note: At the time of this writing I’m using Unity 3.4 so if you’re a traveler from the distant future, I don’t know how much of this will still be valid)

Quick Overview of custom plug-ins:

Writing a custom plugin is very poorly documented, and anyone who does it pretty much has to figure it all out by themselves. For Android, here’s the process:

1. Write a custom Java jar file.
2. Write a C(++) library using JNI to access the jar file and compile it into a .so file using Android NDK
3. Import the DLL (.so file) into C# script inside unity and access all the magic.

Now, I’m not that great of a C developer, so I opted to do the following instead:

1. Write a custom Java jar file.
2. Use the AndroidJNI helper function embedded in Unity to access the jar file.

The latter method is the one we’re going to use today. Continue reading ‘Accessing the Android Compass through Unity 3D.’

Night Runner – Free Unity Android Game

I’ve been working on several games that require heavy use of the accelerometer functions in Android devices and while I was refining my methods I came up with a simple casual game idea. After about 6 hours of work I had “Night Runner” – a fast paced accelerometer casual game!  Since my dev time on this was really really low I decided to launch it for free (no ads or anything) in the Market Place, just so people could have something fun and simple to play.

More info here


Unity and Android’s GPS

Here’s something that frustrated me for about an hour. Hopefully this will help anyone else who wants to use the GPS with Unity Android since the documentation doesn’t have any examples… not to mention the answer is pretty confusing.

I’ll save you the long story and show you exactly how it’s done. The first thing we have to do is start the iPhoneSettings.StartLocationServiceUpdates function.  Yes, I know you’re on Android… you  have to use this function anyway.  Here’s a test script for you – put this javascript on your main camera and do a test build.

Continue reading 'Unity and Android’s GPS'