Udacity VR Nano degree retrospective ⏳

When I started my Udacity VR Nano degree I knew I was in for a challenge. Now that I’ve successfully completed my final assignment I thought I’d share some lessons learnt. So in no particular order:

  • Use version control. Thankfully I started doing this very early on. I had heard of the benefits and for whatever reason actually took them seriously. I started a religious habit of regularly pushing changes to GIT. I only used GIT to roll back to previous versions of projects hand handful of times, but had I not had the option I would have had a much bigger problems on my hands.
  • Don’t underestimate the time required. Taking on any study that requires large blocks of time can’t be taken lightly. It’s not going to be enough to only do a 30 min stretch at lunch, or an hour once the kids are in bed. You’re going to need a clear half day at least once a week to make real progress. Also make sure you know what’s going to consume your time on projects in any given block. No sense clearing 4 hours for study only to have 3 hours of that time consumed rendering a 4k 360 video.
  • Don’t forget to look after yourself. With pressure on your time it’s easy to cut out things like exercise or time with your family. Don’t do that. Cut out things that are actually a waste of time instead. TV is a big one, but also think of ways of compressing your time. Like listening to audio books while you go for a run rather than reading a book alone.
  • Take breaks. If your mind is cluttered you’re not going to learn as well as you might. I found when I spent more than an hour trying to solve an issue the thing to do was take a 20 minute walk, clear my head, then take another crack at it. It’s amazing how often your mind will solve problems for you when you let it.
  • Take notes. Even if you never refer to them, take them anyway. Do this with a pen and paper (or a tablet and a pencil). It’s all about making the information get in your head. I almost never refer to my notes, I don’t take them to remember later. I take them to remember them now.
  • Try and integrate your life into your study. I did this by using my kids as the target audience for my projects and used them as user testing subjects while developing. It let me spend quality time with them and get some study done. It was also an education for them too so a real win win.
  • Scope out what you’ll need before you begin. I started my course with a late 2009 Mac Mini. While old, it was fine for much of the course. The later parts that required 4k 360 video editing, not so much. This sort of thing can add considerable costs to your study budget so make sure you have a line of sight on this and save accordingly.
  • Get involved in the community. A huge part of successful study for me was the community of learners and educators around the subject. Help others and ask for help when you need it. Don’t waste time beating yourself to death if you get stuck. Solving your problem on a public forum helps everyone else with the same issue in future. So don’t be selfish, ask for help.
  • Be grateful. To your partner for looking after the kids. To your friends for listening to your ramblings about project issues. To your class mates and mentors for helping you along the way. Be grateful.
  • Stick it out. Software development is hard. It’s not supposed to be easy. It is literally constant problem solving. There will be times you’ll think “maybe I’m just not good at this”. Just keep going.

Done: Night at the museum ☑️

I’ve been AFK for a while (holiday) so I just wanted to post the details of the final version of night at the museum I finished a few weeks ago that I delivered as part of my Udacity VR course.

The project went well (in that I passed) but I have to admit it was an exercise in restraint as much as anything. Like a lot of people I tend to have a big plans for everything I make but those plans are not always practical. This project was no exception. While I am ultimately happy with what I created, I do consider it very much a minimum viable project. When it comes to working on assignments like this there are a number of things to consider. First and foremost for me is available time.

I’m totally loving learning VR development, at this point I spend almost all my free time doing it. But working full time and having a young family is a busy time in life, so if I want to progress projects I have to be efficient with my time or things can stagnate. Also I currently pay for my studies via a monthly subscription so every extra month a project slips into comes with a significant extra cost.

Just to give you a few examples of compromises made on this project:

  1. Playing content at each of the stations was fairly limited and doesn’t have much finesse. For example the final build allows the user to play audio from all 5 stations at the same time, this leads to a fairly horrible experience if a user does this
  2. I reused a museum model from a previous project because it was faster than building my own. This means it’s not really an ideal setup. The space feels a little constrained and doesn’t provide much room to move about. Most real museums are quite spacious so it didn’t really fit the aesthetic I was aiming for
  3. I wasn’t that happy with the spatial audio implementation. The environment had a bit to much reverberated for my liking and given more time I would have improved this a bit
  4. There’s no environmental audio, just the content of the stations. I’d preferred to add some atmosphere to the scene just to add the the feel of the place

There are loads of other things that could be better about the final deliverable, but ultimately what was made “did the job”. Creating anything is always a series of compromises and I think delivering something you can live with and (resourcing permitting) can be built upon, is more important than getting things perfect. Perfection, after all, is the enemy of the shipped.

If you’re interested in the projects code, it’s all available on my Github account. Enjoy.

Storytelling​ in VR 📖

It’s hard to not have “all the feels” watching the above video (Ideally in VR if you’ve got a cardboard headset). The creators have done such an amazing job of crafting a great story with some seriously well thought out VR technique.

For example transitions/cuts within a 360 video like this can be very jarring, and require the user to reorientate themselves with each cut. In this video, they’ve used the fixed position of the car interior to ground the viewer. It’s extremely effective at controlling the flow of the experience.

The audio is also exceptional. Not only does the song to a great job of creating an emotional connection to the characters, but the changes in audio based on when the characters are inside or outside the car are just wonderful. Spatial audio at its finest.

Just a beautiful bit of work.

Optimising C# scripts in Unity 🏎

C# logoThe more I create C# scripts in Unity the more I learn about optimising those scripts. With code there are 100s of ways to solve a problem, not all of them efficient, so learning to check your codes performance seems like a must.

Things to look for

So far I’ve come across a few simple things to look out for on the projects I’ve been coding. I’ll post more as I come across them in future.

  • Anything that’s called every frame creates consistent load on the CPU, GPU or both. If what’s called is inefficient or large it will have a negative effect on frame rate. In VR this is particular bad given low frame rates can make your user physically sick. Be sure to look at what’s in the Update and FixedUpdate methods and do your best to optimise the code as much as possible.
  • Working on mobile we will almost always be maxing out the graphics capability of the device. This effects the performance of the Update method. On the other hand FixedUpdated runs in sync with Unity’s physics engine. This will make sure your physics will be the most accurate and consistent. FixedUpdate is called every “physics step”, so is regularly used for adjusting physics (rigid body) objects. Make sure you always put your physics code in FixedUpdate.
  • Avoid using GameObject.Find. It basically requires the system to cycle through all of the GameObjects in the game to find the right one, which obviously is expensive for the CPU. If you know what object we are using ahead of time, define the object at the top of the script and reference it that way. GameObject.Find is useful for testing out ideas, but that’s about it.

Adding spatial audio in VR 🎧

Part of my Night at the Museum project is adding audio descriptions to the objects on display. To do this in Unity I’m making use to the spatial audio capabilities of the Google Carboard SDK.

As with most things in Unity there’s a fairly reasoned logic to how this is done. You need three main things:

  1. An audio source. You can think of this as the media player, it is literally the source of the audio within your environment
  2. An audio clip. This is the actual audio file that will be played by your audio source. So think of this as the song that will be played by your media player
  3. An audio listener. This is effectivly your virtual ears within the virtual world. Normally this is attached to your main camera.

To give you an example of how I this works in practice. I first attached a GvrAudioListener to my main camera. This will allow my player to hear the sounds produced. Next add a GvrAudioSource to a GameObject you want to produce a sound. Now load your audio source (your media player) with an audio clip. There’s a few different supported formats, any old mp3 will work nicely. Just drag your MP3 into the audio click field of your GvrAudioSource. By default the audio will play on wake, so just hit play to enter game mode and you should hear your new audio right away.

For more information on the ins and outs of Google Cardboard Audio capabilities, check out the documentation.

Pro Tip:

If you find your audio doesn’t play, try clicking edit -> project settings -> audio and make sure the “Spatializer plugin” is set to Gvr.

More progress 👨‍💻

Managed to get everything to compile to the phone again. Also, I can move about the place now 🙂

The big issue was around the legacy Google Cardboard SDK junking up the project. Completely deleting all SDK related files, old and new, then reinstalling the new was the quickest solution.

Once that was done, recreating key items like the events system and camera using the supplied GVR SDK components made life relatively straightforward.

Big thanks to synthercat for his wise guidance.

Check out the video below.