Unity3D Navmesh – Sprite always face the screen

Recently, while working on a prototype that mixes a 3D environment with 2D characters, I noticed that when a character traversed a navmesh it would rotate in the direction that it was walking. Truthfully, I’d already noticed this in my other dealings with Unity’s Navmesh, but this was my first foray into using it with 2D characters in a 3D environment. In a normal 3D game you’d expect the character to rotate in the direction that it’s walking, but when you apply that same logic to a 2D character things start to look worse than me attempting to cosplay Hercules.

For what I was trying to achieve, this was unacceptable. So, how to do we ensure that the sprite is alway

Posted by Chris in Development, Game Development, Unity3D, 0 comments
Unity Google Play Services PlayGamesPlatform.Instance.GetAccessToken is empty or null

Unity Google Play Services PlayGamesPlatform.Instance.GetAccessToken is empty or null

Recently, I’ve been playing around with Gamesparks and Google Play Games for Unity to create a turn based game on Android in Unity.

As I was following the tutorial I got stuck with an odd issue that prevented me from being able to get an access token back from the Google Play service for the device I was using.

I struggled to find an answer to this online, but then it clicked… The Google Play Games popup authorisation window never appeared.
So, first thing I tried to do was get that to display using the following code:

Now, in theory that should have worked perfectly well. However… that crashed the Unity player. Why? Well, after some digging around I found a comment on an issue in the Play Games Plugin For Unity Github by Tolgau that pointed to the issue being with the version 10.2.0. The work around was to replace all the 10.2.0 .aar files in the Android plugins directory with the 10.0.1 version. Following the instructions worked like a charm.

I deployed the game to my Android device, and lo and behold the Google Play Games window appeared, and after I authorised the app I started getting an access token from the PlayGamesPlatform.Instance.GetAccessToken() method.

Posted by Chris in Game Development, Unity3D, 0 comments
NGUI: Tabbing between input fields

NGUI: Tabbing between input fields

One of the most important features of a multiplayer game is the ability for a user to log in, especially if you want to be able to save their progress. Maybe not always, but for the game I’m currently working on it’s pretty important. Everything was going along quite swimmingly. The API endpoints were working perfectly. I’d created a basic login UI which took the data and passed it to the API. Basically, it was functional, and that’s pretty important.

For the current stage of development I was happy with how it looked. But there was one issue that was really bugging me. The user experience with the form was terrible.
To change fields you had to manually click into the next field. With my day job being a web developer, this really frustrated me. I should be able to tab into the next field, and shit+tab into the previous field.

My limited Googling of the issue took me to a NGUI forum post where the only solution was to script the tab functionality. Someone had provided a script, which collected the child inputs then did event dispatching and listening, which is nice and fancy, but didn’t really suit my use case.

So I wrote a simple script that does exactly what I needed.

The code itself is very simple. It first checks to make sure that the input the script is attached to has focus (or isSelected as NGUI calls it). The it checks the input. It also checks to see if the target input is null to avoid errors, because there are times when you may not have a next or previous input to tab to.

The script has two public UIInput variables:

So, all you need to do is drag the next and previous game objects into the nextInput or previousInput fields in the inspector.

Currently, this doesn’t take into account buttons or other field types. But for simple forms this should be more than enough.
You can download the entire script on Github(https://github.com/chrisbegg/nguiinputtabs).

Posted by Chris in Development, Game Development, Unity3D, UX, 0 comments