Epic Games came out swinging with the announcement that the fourth iteration of the Unreal Engine will be free outside of a small 5% cut of gross revenue.
Not to be outdone, Unity Technologies quickly took command of the stage by announcing the release of Unity 5, noting that the free version of Unity would have access to all the features of the professional version.
Then, to make crazy week even crazier, Valve officially announced their latest game engine called Source 2 which will also be free for all developers although the details of the program are still under wraps.
At this point, it’s not hard to feel like an audience member at an Oprah taping. Needless to say, it’s an exciting time to be making games!
We, here, at raywenderlich.com have produced a variety of Unity tutorials over the years, so naturally, we’re all very excited with the latest Unity updates. In this article, I’ll be providing an overview of some of the changes that Unity 5 brings to the table and in the process, covering the following major features:
- Physical Shaders
- Real-time Global Illumination
- Reflection Probes
- Audio Mixer
- Physics Engine
- Metal & IL2CPP
- 64 Bit Editor
- Cloud Builds
- Licensing Changes
There’s actually a whole lot more, but we didn’t want you to take a day off work to read this article! :]
Physical ShadersWith the build up to the Unity 5’s release, there’s been a lot of talk about Unity’s Physical Based Shading system. If you read the documentation, you’ll see it described as a “user friendly way of achieving a consistent, plausible look under different lighting conditions”.
Practically, this means, you’ll be using one shader to do 95% of the heavy lifting.
That’s right, you’ll be using this one shader to tweak to your heart’s content to replicate a vast array of materials such as wood, metal, hair, skin, or even stone. The shader can take several textures for input and for those slots that you don’t use, they are optimized out of your project so there is no performance hit. According to Unity Technologies, the idea of physical based shading isn’t meant to produce “realism”, but rather, model how achieve a consistent look and feel in a variety of lighting situations. Basically, how things would really look under different lighting conditions.
For those shader writers out there gripping your chair in white knuckled panic, you can still write your own shaders in Unity and if you need to use any of the Unity 4 shaders, they are available to use as well. They are categorized under Legacy Shaders which tells us they won’t be around for much longer.
Unity Technologies hopes that you won’t have write any new shaders. In fact, in one article, Physical Shaders were referred as the “one shader to rule them all”. That said, for the indie developer this is a great tool to get awesome looking visuals without having to learn any of the shading languages.
While Physical Shaders are enough to warrant an article in their own right, one of the biggest changes is known as Global Illumination. The idea behind Global Illumination is to calculate lighting effects not based just a global light source, but on reflective surfaces as well. This tends to be very expensive, but Unity gets around it by using a lot of pre-calcuations.
Unity has managed to make this scale from mobile to desktop, giving you the ability to create easy day night cycles in your games, but also create some dynamic realtime lighting to enhance certain moods. One big practical benefit is that this new system does away with Beast Lightmapping in Unity 4.
Mind you, you can still bake your lightmaps, but it’s now all done for you in the background so there’s no need to click a “bake” button anymore. This is what Unity calls “Iterative Light Baking”. Basically, once you finish making an adjustment on a light, Unity will automatically bake the results for you. If you change a different light, it will simply recalculate, and re-bake without you having to worry about it.
According Unity’s documentation, “a probe acts much like a camera that captures a spherical view of its surroundings in all directions.” The image is stored as CubeMap which you can apply on reflective materials. These probes can be realtime, but you can also have them baked if you are concerned about performance.
Audio MixerWhen dealing with a lot audio sources, balancing the various levels could be a somewhat frustrating experience. Unity 5 now offers an audio mixer asset. You can use this asset to pipe all your various audio sources into it. From there, you can adjust each various level. You can create sounds that are “children” of other sounds, so when you decrease the level of one audio source, the children sounds will decrease.
Typically, when working in play mode, any changes you make in a scene are dropped once stop the game. The mixer will actually keep your changes, allowing you to set your correct levels while the game is being played.
It will probably take time for some of us to get used to the idea of making lasting changes in play mode, and it may even cause a little confusion in regards to other GameObject and components, but it’s a great feature to have.
Unity’s physics engine received a big upgrade in this latest release. The underlying PhysX engine was leveled up to version 3.3 which according to the documentation is an entire rewrite.
One big benefit was that Continuous Collision Detection (CCD) has been improved. CCD is useful when working with fast moving bodies. In previous versions of Unity, if a body moved too fast, it would pass through another, even with colliders enabled. According to Unity Technologies, this issue should be a thing of the past, but we’ll have to see in practice.
The wheel collider component also received a makeover. The wheel component can now be used to create realistic suspension and tire friction. Behind the scenes, Unity is using PhysX3’s vehicle SDK. You can use this to create your own vehicles as shown here.
Unity has also updated their cloth simulations. They’ve done away with the Interactive Cloth and Skinned Cloth replaced it with just Cloth. The idea was to give developers flexibility while also making it inexpensive. By default, cloth does not interact with the world. You have to add colliders and even then, cloth will not apply force to the world. It will only receive force. That way, it can be both dynamic while also being low cost to use in your game.
If you’ve done any work with Unity’s animator, you will have quickly run into situations where you have connections going everywhere. With Unity 5, we’ve been giving state machine transitions so now we can hook up state machines with each other. Each individual state machine has its own entry and exit nodes allowing you to customize the animations for a particular behavior.
For example, you could create an expansive set of animations for your idle behavior, but have it all self contained in the individual state machine. Once a user stops moving their avatar, you could then transition them into the Idle machine, and from the entry point, randomly select a particular Idle animation.
How would write such code?
Easy! By using state behaviors! State behaviors, simply put, are callbacks for your state machines. We now have OnStateEnter, OnStateUpdate, OnStateExit, OnStateMove, and OnStateIK. This will allow you to call your code for particular events in your state machine.
What’s even cooler is that Unity now has something known as a Asset Creation API. This means you can create Controllers, StateMachines, States, BlendTress, and Layers all in your own code.
While the Unity player is pretty awesome, it requires the user to download software to their computer, then enable the plugin on their browser. For those knowledgable Unity, this is not a problem at all, but for those who did not know anything of Unity, this is may be asking too much of them. With the amount of malware, adware, and spyware out there, the Unity player gives people pause. From a security point, this is a good thing, but from a game developer’s perspective, this is just another hurdle for the user.
With Unity 5, you will soon have the option to publish your content to WebGL. This means that your game will be able to played in any browser that supports WebGL. This means no plugins. No players. All the user has to do is navigate to a web page and they can start playing right away.
Unfortunately, at the time of this writing, the WebGL player still isn’t ready for primetime. Unity has stated the current Unity player will continue to ship throughout the Unity 5.x lifetime. In fact when the WebGL player is first released, it will only support Chrome and Firefox. You also lose a few features as well such as webcam and microphone access for starters.
That said, it will probably be awhile before it reaches mature status, but when it does, the WebGL player will be a welcome relief for users uneasy with downloading third party software and that’s always a good thing.
Metal & IL2CPP
In the 2014, Apple released a new API called Metal that allowed for better graphics performance on their devices. Unity Technologies was quick to respond that were planning to take advantage of the API. Well, many months later, you now can leverage the performance benefits of Metal in your own game. When you build for an iOS device, the graphics API is set to automatic, meaning it will use Metal if it is available. You can also manually select Metal, meaning your game will only run on a A7 based device. As the years progress, Metal will ultimately be available on all iOS devices which means faster games for everyone.
Unity 5 also introduces a technology called IL2CPP which simply translates to “Intermediate Language to C Plus Plus”. In short, Unity is now taking our compiled script assemblies from our game, and rewriting them in C++. What this means is that we are getting native performance on certain platforms. Being still a very new technology, it currently will only be available on iOS and WebGL. Unity plans to extend this to all platforms in the future. From Unity’s GDC keynote, the performance benefits were impressive. I’m sure we’ll be hearing more about this technology as it matures.
64 Bit Editor
One of the strongest criticisms leveraged against the Unity development environment was that it was 32 bit. Jeff LaMarche wrote a blog post not too long ago about why he was switching from Unity to Unreal and one of the primary reasons was because the editor was 32 bit. Jeff was working on a game at his company MartianCraft and with all the assets involved, he quickly ran into that 32 bit ceiling. Once you hit that ceiling, the app becomes unstable.
Thankfully, Unity 5 is now a 64 bit application so unless you are truly making an unbelievably massive game, you shouldn’t run into any memory issues.
Unity also unveiled their product known as Cloud Builds. While it is not exactly a Unity 5 specific feature, it still bears mentioning.
In short, you keep your project in a source control repository whether it be Git, Subversion, or Perforce. Once you commit a change to your project, Unity pulls a copy of your project into the cloud and builds it for you. Once the build is complete, an email is sent out to all the stakeholders who can then download the build to their devices and start testing it.
The service does start with a free version and then, like the editor, quickly scales up on price depending on your needs. The free allows you to create projects up to 1 gig is size.
In previous versions of Unity, various features were gated, depending on whether you were using the free version or the professional version. Thankfully, with the release of Unity 5, everything is now unlocked by default. This isn’t too much of a big deal as these features were quite specific to certain needs such as audio filters and advanced water. It does make sure that everyone is on equal footing.
Like Unity 4, we still have two versions of Unity: Unity Personal and Unity Pro. Unity Personal is only for developers or studios making less that 100K per year, so if you just scored big time with your latest Kickstarter, you’ll have to start paying for the professional version.
As for cost, well, that’s a matter of perspective. Game engines used to cost hundreds of thousands of dollars. In such light, Unity is actually a steal. The base editor will set you back $1,500. After that, you may want to purchases add-ons for both iOS and Android. Those add-ons will also cost you an extra $1,500 a piece, so if you are looking to create a truly cross platform game, you’ll be paying $4,500.
Keep in mind that you can publish to mobile devices without the pro add-ons so you don’t necessarily have to purchase them. The pro-addons basically provide a profiler so that you can determine any performance related issues. They also provide Occlusion Culling for those platforms which also gives your game a performance boost by not drawing unnecessary geometry.
What Wasn’t Covered?
A whole lot of things.
For example, for Unity 2D users, we now have effectors that apply physics in various different ways, depending on the effector. A area effector works like a conveyer belt, pushing objects away from it. Unity also provides Frame Debugging now, allowing you to see all the draws calls in a particular frame. Skyboxes have been completely reworked and the list goes on and on.
If you are interested in reading all the changes, then do yourself a favor in check out the release notes. You won’t be disappointed.
The key issue to keep in mind: Unity 5 isn’t a point release masquerading with a higher version number, this is the next evolution of the platform. If you are currently using Unity 4, especially doing 3D game development, then it’s time to make the jump.
Just a quick note of caution … make sure to always backup your project before starting Unity 5. Unity has to process your older projects to make them compatible with Unity 5. I’ve heard some accounts of this breaking projects. I’m also not sure if you can back port to Unity 4, so make a backup before you take the plunge.
And yes … you can run Unity 4 along with Unity 5. If you are using a Mac, rename your Unity 4 folder to something other than Unity. I call it Unity46. Then, download the new Unity installer. That way, you can still manage Unity 4 and Unity 5 projects from the same machine.
Where to Go From Here?
Although just recently released, there are a lot of resources already available for Unity 5. Unity has a great article on Global Illumination over here. They also produced a great video on Mastering Physical Based Shading for Unity last year. Unity has produced an excellent tutorial video demonstrating the new Audio Mixer. They also have a great video detailing on the changes in the animator.
Also, keep checking back here as we will be posting new Unity 5 tutorials.
It’s a great time to be a game developer. Now enough reading, go on and make your game! :]