VR Dev School

Lee Wasilenko of British Columbia has put together some solid intro to VR Development training at VRDev.school (all the new domain name options still trip me out). I’m enrolled in the Vive Developer Mini Course so that I can start making content for my HTC Vive. Probable first project: adding controller support to my bowling game.

Screenshot of VR Dev School course listings.

Free 3D Scan Models for Projects

One of the more common issues that I run into as a tutorial author is finding assets (models, textures, reference images, etc) that I can use and redistribute. Three D Scans (a project by Oliver Laric) is a wonderful resource for free Royalty Free high-quality models for render tests.

Space Shooter

While I’ve taken a few Unity projects from start to finish, I think there’s always a benefit to reviewing the basics. To that end, I’m going through the Space Shooter Tutorial. I’m not much of a videogame player, but I’ve always loved top-scrolling games – which is why I’m particularly excited to start down this road.

  1. Introduction
  2. Game Setup, Player & Camera


    Added a background with an unlit texture. I wish that C4D would allow you to drag an image directly onto an object from the Content Browser.
    MoveIt

  3. To create something that shoots:
    1. Add a Quad
    2. Add a texture
    3. Add a Mover script (Set starting velocity)
    4. Turn it into a prefab
    5. Drag/Drop prefabs into the playing game to see the shots move.
  4. Boundaries, Hazards & Enemies
    1. Boundaries allow you to kill objects that aren’t on screen, saving precious resources.
    2. OnCollisionEnter can be used to detect intersections and destroy.
      Destroy
  5. Soring, Finishing and Building the Game

VR-Ready Laptop / Desktop Research

I settled on the HTC Vive as my VR Platform of choice after a really compelling demo at the MAXON US Offices. I put in my order, and expect my Vive to arrive in just a couple days. At the moment, I’m using a 2013 MacBook Pro – which just doesn’t have the horsepower to drive the Oculus or Vive. Which means, I need to drop MacOS and get a Windows PC. I love the form-factor, weight, and build-quality of my Macbook and that I don’t have to juggle work between a desktop and a laptop when I want to move from home to a cafe or to teach on-site.

Options

  1. Keep my MacBook and get a Desktop for VR development.
  2. Get a Razer Blade laptop with a semi-permanent external graphics card enclosure.
  3. Get a comically large laptop with a built-in desktop GPU.
Mac + Desktop Razer Blade + Razer Core Giant Laptop
Pros
  • Inexpensive
  • Most Power
  • Cheap Storage
  • Light & Portable for Office work.
  • Excellent Battery Life
  • Upgradeable Graphics
  • One Machine
  • One OS
  • Files in One Place
  • Solid Portable Performance
  • GPU Can be Upgraded
  • Good Battery Life
  • One Machine
  • One OS
  • Files in One Place
  • Good Performance
  • Reasonably seamless VR workflow
Cons
  • VR Isn’t Portable
  • Mixed OS
  • Duplicate efforts
  • FileSync Issues
  • Aging Performance
  • Razer Core isn’t available yet
  • Most Expensive
  • Some hitches in VR workflow
  • Can’t do VR work Remotely
  • Expensive
  • Heavy as Heck
  • Terrible Battery Life
  • Not Great for Cafes
  • Can’t be Upgraded
Overall Low startup costs, upgradable, and best VR workflow. VR development only happens at my home office, and my laptop will slowly gather dust. If the kinks in the VR workflow get ironed out, this is probably the best option moving forward – but it means I’ll be buying a new laptop every 2 years instead of every 3-5.  This is a laptop in name only. The weight and battery life is such that I would be unlikely to take it with me, and that I would be forced to drive rather than walk a few miles w/ it strapped to my back.

Conclusion

There aren’t any good and portable laptops for VR at the moment – so give up on the belief that it should be possible right now. Buy or build an inexpensive desktop that meets the needs of the HTC Vive & Oculus Rift. Once the dust in the marketplace settles a bit, upgrade that desktop as needed and buy a laptop once a VR-Capable laptop is available and portable.

I Just Copy / Pasted a Script from the Unity Docs, Why isn’t it Working?

I just tried to copy/paste a script from the Unity Website – specifically a script for quitting the game when the player presses Escape. But then it didn’t work… what went wrong? Here’s the process I went through to discover and correct the issue:

  1. I created a new script called “GameController”

  2. I pasted in the code from the website:

  3. but for some reason, it didn’t work.

    The associate script can not be loaded. Please fix any compile errors and assign a valid script.

  4. I tried removing and re-adding the script, and got this error:

    Can't add script component 'GameController' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.

  5. After a bit of poking, I disovered it was this line that got me in trouble:

public class ExampleClass : MonoBehaviour {

What’s wrong with this line? The filename was GameController.cs but the class name was ExampleClass. So, how do we fix it? Either rename your file to ExampleClass.cs or modify the code to match the name of the script (which is what I recommend):

public class GameController : MonoBehaviour {

This will also sometimes happen when you rename a script file, because Unity isn’t smart enough to refactor (aka auto-update the names in) your source code.

Adding Text to a Unity Game

To add a text UI element to your game:

  1. Hierarchy > Create > UI > Text
  2. A Text object will be added to your hierarchy.

To place the text in the upper left corner

  • Select the text object, and examine it in the inspector:

  • Click on the “Anchor Presets”

  • Hold down Shift + Alt and click on the upper left option

Making Objects Float Up & Down in Unity

Ever wanted to make an object float up and down while spinning in Unity? Well, I’ve written a script for that.

End Result of Script

Usage

  1. Select an object in your Unity project.
  2. Add Component > New Script
    1. Name: Floater
    2. Language: C-Sharp
  3. Edit the script
  4. Copy & Paste the code below into your script editor.
  5. Save the script.
  6. Tweak settings to your heart’s content

// Floater v0.0.2
// by Donovan Keith
//
// [MIT License](https://opensource.org/licenses/MIT)

using UnityEngine;
using System.Collections;

// Makes objects float up & down while gently spinning.
public class Floater : MonoBehaviour {
	// User Inputs
	public float degreesPerSecond = 15.0f;
	public float amplitude = 0.5f;
	public float frequency = 1f;

	// Position Storage Variables
	Vector3 posOffset = new Vector3 ();
	Vector3 tempPos = new Vector3 ();

	// Use this for initialization
	void Start () {
		// Store the starting position & rotation of the object
		posOffset = transform.position;
	}
	
	// Update is called once per frame
	void Update () {
		// Spin object around Y-Axis
		transform.Rotate(new Vector3(0f, Time.deltaTime * degreesPerSecond, 0f), Space.World);

		// Float up/down with a Sin()
		tempPos = posOffset;
		tempPos.y += Mathf.Sin (Time.fixedTime * Mathf.PI * frequency) * amplitude;

		transform.position = tempPos;
	}
}