Explore Free Unity Storytelling Tutorials – GameDev Academy https://gamedevacademy.org Tutorials on Game Development, Unity, Phaser and HTML5 Tue, 11 Apr 2023 10:09:56 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://gamedevacademy.org/wp-content/uploads/2015/09/cropped-GDA_logofinal_2015-h70-32x32.png Explore Free Unity Storytelling Tutorials – GameDev Academy https://gamedevacademy.org 32 32 Unity Tutorial – Create a Simple Fire Particle Effect https://gamedevacademy.org/fire-particle-unity-tutorial/ Tue, 11 Apr 2023 10:09:56 +0000 https://gamedevacademy.org/?p=19695 Read more]]> Have you ever thought how different your favorite games would be without effects?

Things such as sparkles shot from magic wands or fire sparks coming from a bonfire are small details that can add much more credibility to the sceneries and games we create. They are also an important aspect of “game feel” that can just, in general, improve the user’s experience with the game. So – as you can imagine – it doesn’t hurt how to learn to do them as a developer.

In this quick tutorial, we’ll show you how to make fire particles in Unity. We’ll go over the settings and adjustments needed to bring your particles alive inside this powerful game engine. Moreover, you’ll also have a glimpse of the numerous features Unity has already available for you to explore when designing your particle systems.

Let’s dive in!

Project Files

You can download a copy of the source code files for the project done in this tutorial here.

This tutorial assumes you have a few basics of Unity and, most importantly, that you have Unity installed. Also, just to be clear, we are using Unity’s default particle system, not the VFX graph. That’s a tutorial for another day. 😉

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Unity’s Particle System

First, let’s create a particle by right-clicking in the Hierarchy and selecting Effects > Particle System:

Creating a Particle System in Unity

In the small pop-up menu at the bottom of the scene, we have several configuration options at the ready:

Particle effect pop-up menu in Unity

We can pause, stop or restart the particle emission by altering the playback time of the particles, and also slow it down by changing the playback speed. By checking the ‘ShowBounds‘ checkbox we can also see how far the particles are reaching:

'Show Bounds' enabled for the particle system in Unity

This comes very in handy for us to quickly test how our particles are behaving. Nonetheless, we have a much richer range of settings for our particle system inside the Inspector:

Particle System tab in the Inspector

Each tab has a different feature you can apply to your particle. We see that the Emission and Shape ones have a little check symbol in front of them, meaning that they are currently enabled for our particle system. The Emission tab controls how many particles we emit over time, while the Shape tab indicates the sort of shape we’re emitting from (a cone, a box, a circle, etc) and sets up the angle and radius, among other properties:

Shape properties of the particle system in Unity

Another tab that’s checked in is Renderer, which allows us to customize how the particles face the camera. Right now they are set to ‘Billboard’ and if we change it to ‘Horizontal Billboard’ we’ll see the particles flat as well but facing the up direction instead:

Customizing the Renderer tab in the Inspector

We can also change the material of the particles in this tab, as well as the trail material. To add any trails to your particles, you need simply to enable the Trails tab:

Enabling Trails for the particle system in Unity

Particle System Properties

Let’s see all these properties in action! We have:

  • Start Lifetime – Dictates how long the particle exists in the world

Going back to the Particle System tab, if we bring down the Start Lifetime property from 5 seconds to 1 second we immediately see how it changes in height, as the particles are only alive for 1 second now:

Changing the Start Lifetime property of the particle to 1 second

To add a more organic feel to it, you can click on the arrow next to the value entered and select “Random Between Two Constants“. You can then enter two numbers, such as 0.5 and 1.5:

Setting the Start Lifetime property to be a 'Random between two constants'

Note how the particles don’t all disappear at the same time anymore. We can do so with the Start Speed property as well to add more variety in how fast the particles are emitted.

We also have:

  • Start Size – how large the particles are when they start out
  • Start Rotation – the rotation of the particles when being emitted
  • Start Color – the color we want the particles to be
  • Simulation Space – designates the spread of the particles in the world

If we switch Simulation Space from ‘Local’ to ‘World, we see that the particles are now being moved along with our cursor to whatever position we place it:

Setting the particle's Simulation Space property to 'World'

Other interesting tabs are Velocity over Lifetime and Color over Lifetime, where we alter the speed and color of our particles over their lifetime periods. We can use the latter to make our particles fade out as time goes by:

Making the particle fade over time in the Color over Lifetime tab

Or have multiple colors to our gradient as follows:

Adding multiple colors to the gradient of the particle in Unity

Going to the Size over Lifetime tab, it allows us to change how large the particle is over time, based on an animation curve as seen below:

Setting up the size of the particle in the Size over Lifetime tab

You can edit the curve by adding points to it and the particle will reflect the changes directly:

Editing the curve for the size of the particle in Unity

The Noise tab is also helpful to add some randomness and organic movement to our particles:

Noise tab in Unity

Remember to be careful of the Collision tab, as it adds a collider to every single particle and you may have an impact on performance by having too many of them. You can add colliders to make an explosion effect and also trigger an OnCollisionEnter function for that, for example.

Let’s put all this to use by creating our fire particle!

Fire Particle in Unity

Create a new particle system and name it “Fire Particle”. From there, let’s change how the particles look by setting the Render Mode to Mesh and the Material to Sprites-Default in the Renderer tab:

Changing the appearance of particles in Unity

In the Particle System tab, set Start Lifetime to 1 – 1.5, Start Speed to 0.2, and Gravity Modifier to -1. Also set Shape to Sphere and Shape Radius to 1 (or 0.5) in the Shape tab:

Setting up the Particle System in Unity

Next, enable the Color over Lifetime tab, and set the Color gradient to the one below:

Setting the color for our particles in Unity

Back to the Particle System tab, set the Start Size to 1 – 1.5:

Setting a Start Size for the particles in Unity

Enable the Rotation over Lifetime tab, and set the Angular Velocity to 45 – 90:

Enabling Rotation and setting up an Angular Velocity for the particle system in Unity

Also enable the Size over Lifetime tab, and set the Size curve to the one below:

Setting up the size curve for the particle system in Unity

You can bring the first point more to the left-up corner for the fire to get bigger faster as well, and then it’ll get smaller as time goes by. Feel free to tweak this as you like.

Finally, set Rate over Time to 20 in the Emission tab:

Setting the emission rate over time for the particles in Unity

If we change the background color of the camera to a solid black, we can better visualize our fire particle all set up:

Fire Particle in Unity

Notice how it’s changing color and has the fading-out effect, just as wanted!

Conclusion

Well done on concluding this tutorial!

Here you learned how to create simple fire particles in Unity in a fast and easy way! This is your first step towards designing all other sorts of particles, whether you want portal effects, magic attacks, or more. Unity allows us to customize our particles quite a lot through its default Particle System, and the more you explore it the more organic your particles will look.

We encourage you to practice with the Particle System more and try coming up with unique designs on your own! You may also want to take a look at Unity’s VFX Graph at some point as well, which takes particles to a whole new level with more power and performance – and much of the same fundamentals at play.

Regardless, good luck with your games, and we hope they “feel” that much more exciting!

Want to learn more about particles in Unity? Try our complete Intro to Particle Systems for Games course.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
How to Work with Audio Mixers and Volume Settings in Unity Projects https://gamedevacademy.org/unity-audio-settings-tutorial/ Fri, 07 Apr 2023 09:33:28 +0000 https://gamedevacademy.org/?p=19992 Read more]]> Although we’re not always aware of all the different sounds present in a game, they play a huge role in immersing us and providing interactive feedback. Ranging from the simple sound of footsteps to ambient music, sounds can make us relax or grow tense while we’re playing.

That said – would it surprise you to learn that balancing audio is hard and not everyone wants that gushing waterfall overriding the character dialogue? This is why, for many players, having sound settings is super important so they can customize the experience to their needs.

In this Unity tutorial, we’ll go through how to set up sound settings for the master volume, as well as the volumes for sound effects and music. For that, we’ll take a look at the audio mixers in Unity, its different groups, and how to create a canvas with sliders for each group that the players can adjust to their liking.

Let’s get started!

Project Files

You can download a copy of the source code files for the project done in this tutorial here. This tutorial requires good familiarity with Unity and C# scripting.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Audio Mixers

The Audio Mixer feature of Unity allows you to mix various audio sources, apply effects to them, and perform mastering. It is an asset that we can create by going Right-click > Create > Audio Mixer:

Creating an Audio Mixer in Unity

You can double-click on the icon to open up the Audio Mixer window:

Double-click on the icon to open up the Audio Mixer window

Audio Mixer in Unity

By default, we have the Master group, which overrides every single audio source in the game. This allows us to adjust the Pitch and the Volume of the overall audio of the game in the Inspector:

Adjusting the Pitch and Volume of the Master

Modifying Audio in Script

In order to modify the volume in a script, we need to right-click and select ‘Expose Volume (or pitch) to script‘:

Modifying the volume in a script in Unity

Now it will appear in the Exposed Parameter dropdown list:

Exposed Parameter dropdown list in Unity

Audio Mixer Group

To create a new group, you can click on the + button in the Groups section. We’re going to create two new groups, which are Music and SFX for sound effects:

Creating a new Audio Mixer group in Unity

Creating 'SFX' and 'Music' groups for sound effects in Unity

Now that we have SFX and music as children of the master group, we need to assign these to specific audio sources. For example, if you select the Player object of your project, you’ll see there is a property called Output inside the Audio Source component. This is where our Audio Mixer Group is going to be sending the modified audio in:

Setting up the Output property inside the Audio Source component

If you assign this to the SFX group, you will be able to modify the output inside of the Audio Mixer window:

Assigning the SFX group as Output in Unity

Modifying the groups inside the Audio Mixer window in Unity

Volume Settings

Next, we’re going to be setting up the visual UI (User Interface) for volume settings.

Creating UI Canvas

First of all, we’re going to create a new GameObject called Canvas, which contains all of the UI elements.

To create a canvas, right-click on the Hierarchy > UI > Canvas:

Creating a Canvas in Unity

Canvas object listed in Unity's Hierarchy

If you select the Canvas and press F, the screen will be zoomed out to focus on it:

Press F to focus on the selected object in Unity

Adding Image To Canvas

To add an Image object to the Canvas, we’re going to right-click on Canvas and go to UI > Image:

Creating an Image in Unity

As you can see, it has created a brand new Image object, which is a child of Canvas:

The Image object as a child node of Canvas

Let’s rename this Image to ‘VolumeSettings‘:

Renaming the Image to 'VolumeSettings'

Resizing Canvas Components

To change the size of the element, you can drag it around with the Rect tool selected:

Using the Rect Tool to change the size of the image

You can then click and drag on the blue circles to change the size of the image:

Click and drag the blue circles around to scale the image in Unity

Or you can click and drag on the sides to resize them along that specific axis:

Resizing the image on specific axes in Unity

Alternatively, you can set the specific Width and Height using Rect Transform in the Inspector:

Setting specific values for Width and Height in the Inspector

Resized image on canvas in Unity

We’re going to click on the Color property of the Image component and change it from white to black:

Changing the color of our image in Unity

Black image on canvas in Unity

Adding Text

We recommend you use TMP (TextMeshPro) instead of Unity’s default Text because it provides more flexibility in font settings:

Using TextMeshPro for more flexibility in font settings in Unity

You can import the package when adding the first TMP object to the scene (Right-click > UI > Text – TextMeshPro):

Importing a TextMeshPro in Unity

Once that’s complete, you can give it a new name (e.g. ‘HeaderText‘), type in a header (e.g. ‘Volume‘), and modify the font settings in the Inspector:

Renaming the TextMeshPro in Unity

Modifying the font settings in the Inspector

Displaying text for the HeaderText in Unity

What we’re going to do now is create three separate sliders for adjusting the Master Volume, the SFX Volume, and the Music volume as follows:

Separating each volume group into different sliders

To create a new Slider, right-click on the sub-heading (e.g. “Master Volume”) and select UI > Slider:

Creating Sliders in Unity

Slider for the Master Volume

You can then scroll down to the Slider component in the Inspector to set the Min Value and the Max Value of the slider. Since we’re working with dB (decibels), the maximum value would be the original volume of the audio clip, which is 0 dB, and the minimum value would be -40 dB:

Min and Max Value settings for the Slider component in the Inspector

We can then duplicate this by pressing Ctrl + D (or Cmd + D):

Duplicate the Slider by pressing Ctrl + D (or Cmd + D for Mac)

Sliders for the 3 volume groups (Master, SFX, and Music)

Scripting The UI

Now that the UI objects are all set up, let’s create a new C# script called “Volume UI” and attach it to the parent Canvas object:

Create a new script called "Volume UI" and attach it to the Canvas

Volume UI script

Inside the script, first of all, we need to import the TMPro, Audio, and UI library at the top of our script to be able to utilize these features in our script:

using TMPro;
using UnityEngine.Audio;
using UnityEngine.UI;

And then we’re going to declare a few public variables so we can access and modify the UIs that we created earlier:

public class VolumeUI : MonoBehaviour
{
    public AudioMixer mixer;
    public GameObject window;
    public Slider masterSlider;
    public Slider sfxSlider;
    public Slider musicSlider;
}

Then we need to create a new function called “SetSliders” to load the saved volume settings (float) from PlayerPrefs, for instance.

PlayerPrefs is an easy way to store and access important data between game sessions. For more information, refer to the documentation: https://docs.unity3d.com/2020.1/Documentation/ScriptReference/PlayerPrefs.html

// called at the start of the game
// set the slider values to be the saved volume settings
void SetSliders ()
{
    masterSlider.value = PlayerPrefs.GetFloat("MasterVolume");
    sfxSlider.value = PlayerPrefs.GetFloat("SFXVolume");
    musicSlider.value = PlayerPrefs.GetFloat("MusicVolume");
}

This function is going to be called at the start of the game, so the player doesn’t have to reset the volume settings every time they open up the application. That being said, if there is any saved volume property found in PlayerPrefs (HasKey), then we need to set the mixer volume levels based on the saved PlayerPrefs before setting the sliders:

void Start ()
{
    // do we have saved volume player prefs?
    if(PlayerPrefs.HasKey("MasterVolume"))
    {
        // set the mixer volume levels based on the saved player prefs
        mixer.SetFloat("MasterVolume", PlayerPrefs.GetFloat("MasterVolume"));
        mixer.SetFloat("SFXVolume", PlayerPrefs.GetFloat("SFXVolume"));
        mixer.SetFloat("MusicVolume", PlayerPrefs.GetFloat("MusicVolume"));
        SetSliders();
    }
    // otherwise just set the sliders
    else
    {
        SetSliders();
    }
}

Now what we need to do is set up a new function for when we modify the master slider value:

// called when we update the master slider
public void UpdateMasterVolume ()
{
}

The UpdateMasterVolume function is going to be called whenever we modify the master volume slider. Inside here, we’re going to set the MasterVolume exposure parameter to be the masterSlider‘s value. Then we can save it in PlayerPrefs using SetFloat (which is similar to saving data, whereas GetFloat is similar to loading data):

// called when we update the master slider
public void UpdateMasterVolume ()
{
    mixer.SetFloat("MasterVolume", masterSlider.value);
    PlayerPrefs.SetFloat("MasterVolume", masterSlider.value);
}

We can do the exact same thing with the SFX volume and the Music volume:

// called when we update the master slider
public void UpdateMasterVolume ()
{
    mixer.SetFloat("MasterVolume", masterSlider.value);
    PlayerPrefs.SetFloat("MasterVolume", masterSlider.value);
}

// called when we update the sfx slider
public void UpdateSFXVolume()
{
    mixer.SetFloat("SFXVolume", sfxSlider.value);
    PlayerPrefs.SetFloat("SFXVolume", sfxSlider.value);
}

// called when we update the music slider
public void UpdateMusicVolume()
{
    mixer.SetFloat("MusicVolume", musicSlider.value);
    PlayerPrefs.SetFloat("MusicVolume", musicSlider.value);
}

Toggling A Window

Now what we need to do is make it so that whenever we press a certain key (e.g. V), we’re able to toggle this window open. To detect a key press, we can use the Input.GetKeyDown function:

void Update ()
{
    // toggle the window when we press V
    if(Input.GetKeyDown(KeyCode.V))
    {
    }
}

When the window is active in the hierarchy, window.activeInHierarchy will return true, otherwise, it will return false. We can utilize this to activate/deactivate the window:

void Update ()
{
    // toggle the window when we press V
    if(Input.GetKeyDown(KeyCode.V))
    {
        window.SetActive(!window.activeInHierarchy);
    }
}

If the window is active, we want to enable the mouse cursor (CursorLockMode.None) so the player can click and drag the sliders.

Otherwise, if we’re disabling the window, we’re going to lock the cursor again (CursorLockMode.Locked):

void Update ()
{
    // toggle the window when we press V
    if(Input.GetKeyDown(KeyCode.V))
    {
        window.SetActive(!window.activeInHierarchy);
        // enable or disable the cursor
        if(window.activeInHierarchy)
            Cursor.lockState = CursorLockMode.None;
        else
            Cursor.lockState = CursorLockMode.Locked;
    }
}

We also don’t want our camera to be able to look around when we’re in the volume settings, so inside the Update function of the PlayerController script, we’re going to run the Look function only if the cursor is locked:

void Update ()
{
    Move();
    if(Cursor.lockState == CursorLockMode.Locked)
        Look();
}

Make sure to save the script and drag all the UI objects into the corresponding fields:

Drag the UI objects into their correspondent fields inside the script panel

Adding Script Events To Buttons

We need to link each of those sliders to the VolumeUI script. To do that, we need to select each slider and add an On Value Changed event by clicking on the + icon:

Adding an On Value Changed event for each Slider

Inside here, we’re going to drag in the Canvas object and select the Update (Master/SFX/Music) Volume function as the function to be called whenever the slider value changes:

Settings of the On Value Changed event in Unity

The volume settings window shouldn’t be open at the beginning of the game, so we can deactivate it for now, and press V to open it up in Play mode:

Disable the 'VolumeSettings' option in the Inspector window

And here we have it:

UI volume settings in Unity

Conclusion

Well done on reaching the end of this tutorial!

With this tutorial, you’ve learned how to allow your players to have much finer control over the audio channels of your game in Unity. Whether for user satisfaction or accessibility, this can sometimes make or break your game depending on how needed sounds are for an optimal experience.

However, the learning doesn’t stop here. Feel free to practice by adding more audio channels to the canvas we’ve created. For instance, if your game has dialogues, maybe it’d be interesting for your players to change the volume of that as well. Or, you may want to add a slider for UI sound effects, and so on.

That said, we do encourage you to dive even deeper into more advanced topics and wish you the best of luck in your projects!

Want to learn more about audio in Unity? Try our complete Game Audio Effects for Beginners course.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
The Beginner’s Guide to Unity Certification https://gamedevacademy.org/unity-certifications-tutorial/ Sat, 28 Jan 2023 06:09:24 +0000 https://gamedevacademy.org/?p=19413 Read more]]> How does a Unity game developer prove their skills?

Whether you’re just starting out or have been making games for a long time, this is a difficult question. However, it’s a question that comes up often in the professional world. Numerous situations will require you to show evidence you actually do know what you’re doing.

While portfolios are definitely a necessity, for Unity developers, there is another fantastic option: Unity Certification.

In this article, we will endeavor to explore what Unity Certification is, why Unity Certification is definitely worthwhile to pursue, and how you can start preparing to earn your certification.

Let’s jump in!

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

An Overview of Unity Certification

In this section, we will discuss what Unity Certification is for those new to the topic. If you already have a good idea of what Unity Certification is, feel free to skip ahead to find out why Unity Certification can help you and get guidance on prepping for an exam.

What is Unity Certification?

The Unity Certification program is a set of exams aimed at testing Unity developers’ core skills in game development and the Unity engine. The exams were developed meticulously by Unity through research, and with coordination between both testing specialists and game development experts.

At current, the tests are administered by Pearson VUE, a branch of the widely-recognized educational company Pearson, which is aimed at specifically providing testing for professional certifications. As such, Unity Certifications are regarded very highly in the professional world due to the extensive work and credentials associated with them.

The exams for Unity Certification are divided between a few different specialties and different levels of experience – giving every user an opportunity to pursue certification. Likewise, this division allows the prices to vary – starting as cheap as $60 and going all the way up to $350 for experts (with some bulk purchasing options for schools).

Screenshot of the Unity Certifications available

How are the Unity Certifications Structured?

As mentioned above, the Unity Certifications consist of several different exams depending on your level of experience and your specialty in that experience level. We will briefly discuss what exams are available so you can get a grasp on what you personally may wish to pursue.

Certified User Unity Certification

This is the beginner’s level exam aimed at people who’ve just learned a little bit of Unity. To put it into better perspective, this exam was one that was made to be appropriate for high school level students as well, so there’s no expectation you’ve necessarily even made more than a couple of hobby games.

At this level, Unity offers three different certification specialties, each with a separate exam.

  • Programmer: This is probably what would be considered the main certification for Unity itself at this level. In this one, users are evaluated on how well they know the fundamentals of using Unity, such as how to make projects and Prefabs, navigate the editor, and so forth. This exam will, of course, also test your basic C# knowledge – including quite a lot of focus on Unity-specific library functions and accessing components. However, the main point is to see if you’re able to read, write, understand, and debug basic code elements that will be used all the time.
  • Artist: This level tests how well you know Unity’s tools in order to design 2D and 3D scenes. This includes things like importing the assets correctly and manipulating objects in the scene. You’ll also be expected to know a little bit about lighting, materials, and cameras.
  • VR Developer: For this certification, users are tested specifically on how well they can adapt a Unity project for VR. This includes elements related to understanding how to even set up a VR project, how to deal with movement based on hardware, and how to optimize your elements to be VR-ready.

Certified Associate Unity Certification

This certification is primarily designed for those ready to actually start working in professional development. The general assumption is that you’ll probably already have a few simple projects under your belt, and be ready to justify the fact you can, in fact, build games.

Like the User Certification level, this level also has three different exam options to specialize in:

  • Game Developer: This particular exam focuses on testing whether you can make a game with Unity. While there is some C# programming involved, of course, the major aspects are much larger in scope. You’ll be expected to understand how to take a game from idea to completion. You’ll also be expected to know, relatively well, all the tools Unity offers such as audio, animation, physics, and so forth. Another way to think of it is this exam is for those looking to make sure they understand the bigger picture of game development.
  • Programmer: At the Associate-level, the Programmer Certification focuses a ton more on C# scripting. You’ll be expected to have a solid understanding of working with Unity’s API to script behaviors and objects (including UI elements). This level also starts examining code efficiency, such as if you understand best practices for data structures. There is also a strong focus on being able to debug.
  • Artist: Continuing somewhat from the Artist User Certification, the Artist Associate Certification focuses on more advanced uses of the Unity tools for artistry. This includes working with tools like Shader Graph and ProBuilder, understanding different lighting effects, implementing Level of Detail, and beyond. If it has to do with presenting the assets, be prepared for it to be on this exam.

Screenshot of a splitscreen racing game made with Unity

Certified Professional Unity Certification

The Professional Unity Certification is where we really start getting into more advanced users. This certification level is focusing specifically on those who have probably up to 4 years of making professional Unity games. Another way to think about it is this certification is perfect for those who are already game developers but want that coveted promotion and need something extra to prove themselves.

This level focuses on two specific specializations for its exams:

  • Programmer: At this level, you’re already expected to have long since mastered the fundamentals. So, the focus on this exam turns to more advanced C# programming. You’ll be tested on things like being able to program a render pipeline, working with teams on coding, and even being able to optimize the game with how you code. There is also some focus on applications as well at this level.
  • Artist: At this level, artists aren’t tested much differently than before – the only expectation difference is your level of understanding. As such, you’ll need to be a pro at being able to light scenes, work with particle systems, deal with animations, and similar. There is also a bigger focus on teamwork aspects to ensure you can work with big-budget productions.

Certified Expert Unity Certification

This is the last level of certification, and as expected, it’s focused on the bravest and most experienced game developers. In general, this certification is best for those who have worked with Unity for at least 5 years, if not more. It’s also a relatively safe assumption that if you need this certification, you’re working in the wider game industry as a whole.

At this level, there is only one certification exam for Programmer. The exam focuses on two things. The first is simple project management principles, such as being able to scope the project and review it to polish and refine the game. The second is obviously the coding part – where you’re going to have to know how to work with advanced algorithms and mathematics, as well as evaluate your code to improve it to its utmost efficiency.

Woman working on a laptop

Why You Should Get Unity Certification

So, why should you get Unity Certification? Is Unity Certification worth it? In this section, we’re going to discuss the three major reasons why Unity Certification may help boost your position regardless of your personal goals.

Unity Certification Helps With Job Hunting

One of the core reasons the Unity team invested in their Unity Certification program was to help Unity developers with job hunting.

Job hunting for any position, game development or not, is very tough. You’re generally up against 10s or 100s of other applicants for the same position. Even if your application is lucky enough to get past the initial resume review process, the competition will only get thicker.

As such, the key goal of any applicant is to make themselves stand out from their competition. When it comes to game development, the more you can prove you know how to make games (or provide the subspeciality the company is looking for), the better your standing.

However, almost every game development applicant will have two items: their work history (or education history for those starting out), and their game developer portfolio. So, even if you make great games, you’re going to need to find another angle to help push yourself to the top of the pile.

This is where Unity Certification comes in. In an industry where certifications are extremely rare, Unity Certification stands apart. It is widely recognized as a solid credential to prove your skills due to the exams themselves and the cost & time involved in obtaining the certification. They are so accepted in the industry that a good number of Unity-based job postings will even list Unity Certifications as a preferred requirement for the position.

To put it another way, if you were in HR, who would you hire:

  1. The applicant who has previous experience and a portfolio OR…
  2. The applicant who has previous experience, a portfolio, and certification proving they know Unity

The answer here is probably going to be two – so you can see how Unity Certification can be an extra boost that will help you shine compared to other job hunters. It’s just a good piece of evidence you know how to make games, and since not everyone will get certified, it can only help you professionally speaking.

Unity Certification Prepares Teachers

Teaching is a challenging skill set to develop. Not only do you have to understand the subject matter you’re teaching, but know how to tailor that content to your audience.

This second part is particularly important. If what you’re teaching is too easy for the audience, they’re going to get bored and disengage. If what you’re teaching is too difficult for the audience, they’re going to get frustrated and disengage. There is a reason we don’t teach physics and calculus to kindergartners or teach high school students the Alphabet song.

So, when it comes to Unity, how can a teacher prepare? Surprisingly, the Unity Certification process is a great answer to this.

Obviously, by preparing for a Unity Certification exam, you’ll have to fulfill that first part of actually learning Unity and proving that you do know the subject matter. Thus, this benefit speaks for itself.

However, as Unity divides its certifications by experience level, you can also choose to prepare for the exam that suits the audience you most want to teach. By forcing yourself to prepare for the proper level exam, you achieve two things. First, you make sure you’ve refreshed in your mind the materials most relevant to your audience. Second, you unintentionally use Unity to guide you on what fundamentals you actually need to convey to your students.

So, once you pass your exam, you can use the exam as an example of how you should structure your own learning materials. This helps you save tons of time, and makes sure you have the right direction for what you want students to take away.

As a side benefit, for teachers focused on self-guided learning online by providing online courses, having Unity Certification can also be a great selling point!

Man teaching at a projector screen

Unity Certification Challenges Hobbyists

The last benefit of getting Unity Certification may surprise you – as it has nothing to do with the professional world.

Plenty of Unity developers out there would qualify more as hobbyists. While the professional world may be a long-term goal, the main goal is simply to have fun, make some awesome games, and learn more Unity skills along the way.

That being said, learning more Unity skills is a big component for hobbyists, especially as many are self-taught. And, if you’ve ever tried to teach yourself a new skill, you know it can be extremely hard to plan an ideal learning path. Even with numerous courses out there, you can still often hit a wall at one point wondering, “Where to next?”

This is the sneaky way in which Unity Certification can benefit the hobbyist. As mentioned, these certification exams are divided into different levels, going from beginner to expert developer. While not required, the subtle idea here is you take the certification exams in order since it’s a designed progression.

However, this subtle idea of taking them in order also gives you a core learning path to subscribe to. By following this progression and prepping for each exam, you can challenge yourself to learn exactly what would be expected of you at each level. In this way, you don’t have to question, “What’s next?” Unity Certification guides you exactly on the skills you’ll want to learn in order to hit the next step of your Unity development journey.

Likewise, this means you can more easily choose courses to achieve those goals, plan projects that would implement elements you need to know, and so forth. Plus, if the need should arise, you’ll be ready to take the Unity Certification exams at any point.

Overall, though, Unity Certification can still play a key role for hobbyists and helps describe an ideal path for developers to follow.

How to Prepare for Unity Certification

So perhaps at this point, we’ve convinced you to obtain Unity Certification – or at least convinced you that looking into these certifications is worth your time. This is where we come to our final section: how to prepare for Unity Certification. We’re going to cover the three major steps that will be involved, though the second part of this is the most important.

Understand Unity Certification Testing Procedures

Before you jump into other prep work, you’ll first want to do a bit of research into the Unity Certifications. Even though this seems common sense, it’s also an easy step to just skip over and take the “you only live once” route.

The most important aspect here is to simply tailor your expectations to understand what is required of you when the testing day rolls around. This way you can make sure to set aside enough time to take your exam, and also just generally prepare your environment to best suit your exam-taking needs.

However, you’ll also want to be sure to use this research time to narrow down your focus as well as to which exam you’re actually going to take.

Below, we’ve made a quick list of some of the most crucial information you’ll want to know going into your exam:

  • These exams are proctored – so you are going to have to deal with a person watching over your shoulder.
  • While Pearson VUE does have some scatterings of on-site testing centers, the exams are primarily designed to be taken online.
  • The number of questions varies by exam, ranging from as little as 40 questions up to 100 questions in total.
  • With the possible exception of the User Certification level, the tests are timed. We’ve listed the time limits below, but keep in mind it’s recommended you add an extra 15 minutes to your schedule to allow time for reading instructions and so forth:
    • Associate: 90 minutes
    • Professional: 105 minutes
    • Expert: 165 minutes
  • If you fail, you can retake the test. For a second attempt, you must wait 15 days. Additional attempts require a 90-day waiting period.
  • Unity Certifications are only good for 3 years. You must retake the test routinely to maintain your certification.

There are more questions you might have than we answered here, so we highly suggest checking out the FAQ section from Unity’s own website for further details. Regardless, do the legwork and make sure you have a solid understanding of your specific certification aims.

Screenshot of an AR training app made with Unity

Unity Certification Prep Courses

Perhaps not surprisingly, if you’re going to get a Unity Certification, you kind of have to learn Unity and game development. How much you have to learn will depend on the exam you’re taking – which is why the step above is crucial. That’s the juncture you decide what level you want to aim for, which informs which kind of coursework you want to look for.

This being said, it’s important to consider the kinds of courses you pick. There is no shortage of Unity learning material out there, as it is a very popular engine. However, some coursework is definitely better than others. Our advice? Make sure to pick courses that aren’t aimed solely at exam passing. Instead, you’ll want courses that help encourage you to fully understand game development so you can continue to expand your skills.

We also highly recommend finding courses that have a project-based focus. Not only does this force you to learn in a more practical manner, but also helps you discover different game mechanics and build a portfolio. This way, you essentially kill two birds with one stone.

As a bonus, you may wish to search for courses that are intended as a series (i.e. curriculums). It’s much easier to build your skills consistently when courses are designed around that single idea of continuity. While not required, obviously, it can be a lot easier than picking and choosing courses at random from sites like YouTube or Udemy.

For those just getting started with Unity, though, here are some fantastic resources to start your Unity education off with (all of which are beginner-friendly):

Unity Game Development Mini-Degree

This curriculum is designed around learning a little of everything that Unity has to offer. This includes things such as working with the UI, working with art tools like ProBuilder, using particle systems, building worlds, and so forth. There are also several different kinds of projects featured, including an FPS game, an idle clicker, a kart racing game, and so on.

Virtual Reality Mini-Degree

As the name suggests, this curriculum is all about VR. Of course, you’ll learn the coveted fundamentals of Unity. Past that, though, you’ll get to experience a lot of VR-specific mechanics such as how to get players to move, how to work with different controller setups, and other essential knowledge. The curriculum also covers the XR Interaction Toolkit, which has become a core focus for VR development with Unity.

Retro Game Development Academy

With this curriculum, the focus is entirely on 2D game development. Students will make a constant stream of retro-inspired games such as Pong, platformers, base defense, and more. The curriculum even covers a bit of how to implement local multiplayer as well. Given the simple nature of the projects, this curriculum is fantastic for those wanting to build up their portfolio.

2D RPG Academy & 3D RPG Academy

Although two different curriculums, these resources have the same focus of covering RPG creation (just with different kinds of assets). The courses cover a variety of skills required for these games, including action and turn-based combat styles, roguelike procedural generation, character customization, and beyond.

Strategy Game Development Academy

This course series covers strategy games and their specific mechanics. This includes RTS games, turn-based games, city-builders, and tower defense games. Along the way, students explore a good number of required features, ranging from technology trees to designing enemy AI – all fantastic skills transferable to other projects.

Survival Game Development Academy

This curriculum entry on the list is a bit unique. Instead of many small projects, this curriculum has you build one big, complex survival game project. Starting from the zero-Unity experience, you can learn player mechanics, inventory systems, crafting, base building, and enemy combat. You’ll also get to explore making a save system – a core need for many games.

EdTech Game Development Academy

Last on the list, this curriculum focuses a bit more on making educational game projects and utilizing more advanced technology. Students can learn things as simple as making quizzes with Unity or working with Cinemachine to create cutscenes. On the other end, though, students can also learn to utilize tools like Azure to make voice-commanded applications or to bring in third-party API data.

Police car chase scene animation made with Unity

Take Unity Certification Practice Tests

Last in the preparation steps is something kind of obvious: take practice tests.

Much like any sort of certification or big test like the SATs, there are plenty of resources out there that let you practice the tests. Obviously, legitimate sites won’t have the same content exactly as the exam. However, they will give you a fantastic idea of the sorts of stuff you may have to know and a better understanding of the experience level you’ll need to reach to pass.

This being said, be aware of two things. First, this step is optional. It can definitely help if you’re nervous, but it’s not required. If you feel confident, you can go straight to the exam if you wish. The practice tests are just there if you need them, as everyone practices in different ways.

Second, there are a lot of illegitimate sites out there that offer practice tests. There are evens some shady sites that claim to offer the actual exam in advance. Obviously, this would hardcore violate the Terms for these exams, so they are not recommended.

Instead, your best bet is to actually purchase practice tests from Pearson VUE itself. After all, who better to give you practice exams than the people running the exams in the first place?

There are some free resources available as well, but your mileage will vary with them. However, if you feel they’ll help you practice, by all means, use what you can.

Unity Certification Takeaways

Despite all the big talk, we acknowledge Unity Certification isn’t for everyone. Some developers absolutely prefer going the pure portfolio route – and this is a totally valid way to go about showcasing your skills. In fact, even with Unity Certification, having a portfolio can only help (and it’s also free for the budget conscious).

However, Unity Certification is nothing to ignore either. For many Unity developers, it can be a great piece of evidence to add to one’s resume. On the other spectrum, it can also be a simple way to structure how you learn Unity to ensure the best results for your time. It’s also a very accessible certification compared to others in the tech space. So, all in all, Unity Certification can be a fantastic and worthwhile pursuit to aim at.

We hope this article has given you some essential stepping stones to choose the right path for you when it comes to Unity Certification. Good luck with your Unity game development, and we wish you the best.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Unity Audio Tutorials – A Guide to SFX and Music https://gamedevacademy.org/best-unity-audio-tutorials/ Mon, 23 Jan 2023 08:06:44 +0000 https://gamedevacademy.org/?p=15383 Read more]]> When was the last time you played a game that was completely silent by design?

From ambient background music, UI SFX, or even the sound of footfalls, sound plays an important role in game development. Sounds not only increase the atmosphere of the general game experience, but can also add necessary feedback to player interaction with the game mechanics. Some games have even made sounds a core component of the gameplay. So, all around, while we could technically play games without sound, they can be equally important depending on the sort of game you want to make.

This article will explore this topic and feature the best Unity audio tutorials available. These tutorials will be aimed at getting you up and running with audio in Unity, both in terms of engine available tools and C# scripting. We’ll also explore some less obvious features that you might find helpful with adding some extra “oomph” to your game project.

Let’s dive in, and learn about audio!

Game Audio Effects for Beginners

Duration: 1 hour, 30 minutes

Starting with a premium resource, this course by Zenva is the total package when it comes to audio, as it covers a little bit of everything.

Of course, the tutorial starts of easy showing you how to add and play audio within the Unity engine – whether via component or script. As you explore these concepts, though, you’ll also learn how to perform certain different audio effects. This includes having specific areas for background music, adding SFX, or even doing something as complicated as the doppler effect.

As a bonus, the course also shows you how to make a simple volume control menu. This includes both splitting sounds into different channels, and making a UI. So, if you want to learn a little bit of everything at once, this is a fantastic place to start.

LEARN NOW

Introduction to AUDIO in Unity

Duration: 14 minutes

For developers who have never touched audio as part of Unity, this tutorial by Brackeys is a great starting point.

The tutorial goes over the basics of really just playing audio. However, it does this in a few interesting ways. To start, it covers some of the settings available in the audio components, particularly looping music so you can get a background music effect. It also covers a lot of scripting, from just playing sounds from a C# script, to setting up an audio manager to control when and how sounds are played (though in a beginner-friendly way).

As a bonus, the video also covers the concept of how to handle sounds when switching scenes, which is perfect for dealing with background music for any game.

LEARN NOW

How to add background audio & on-click SFX

Duration: 13 minutes

Aren’t keen on C# coding yet? Well, this tutorial by Erika Verkaaik will help you skip that.

Focusing on Unity’s audio-related components, this tutorial will show you how to set up a scene with background music and SFX for a fire that can be triggered on or off with a simple button. As stated, none of this will require you to code at all, and relies solely on built-in tools offered by Unity. Thus, if you want something quick and dirty, this tutorial will show you how.

In light of that, though, we do want to mention this tutorial is also good for exploring the concept of audio sources in 3D space. This will be very important as you develop more kinds of games, and is also a good bonus to pick up here.

LEARN NOW

Learn UNITY AUDIO (The Ultimate Beginner GUIDE)

Duration: 25 minutes

This tutorial by SpeedTutor is another great beginner’s level tutorial for those just getting started with audio in Unity.

Of course, it covers all the basics you would expect: how to handle Unity’s audio components, how to play audio from a script with triggers, dealing with audio sources in a scene, and even playing around a bit with the audio mixers Unity offers.

Where this tutorial really stands out is its practical approach. Rather than using a menu or featureless level for testing audio, you’ll see everything showcased with a scene that looks completely polished for a finished game. Thus, you’ll learn both how to work with your audio and a bit about the practical design implications for using it in actual game projects.

LEARN NOW

Simple Sound Manager

Duration: 19 minutes

In this tutorial by Code Monkey, you’ll learn some robust C# scripting skills for making a sound manager capable of handling all your in-game SFX.

While there are many different ways for handling audio in Unity, in some cases you may want a static manager to handle every instance you need to play a sound – no matter what that sound is. This can be very efficient in many cases, especially if you later want to add things like volume controls that effect all your sounds at once.

This tutorial will show you how to do just that so you can add sounds like footsteps, sword slashes, UI interaction, and more as players interact through their character. This, of course, will be played with a single sound manager, making sure that no matter what your character does, the appropriate SFX always plays.

LEARN NOW

Manage your sound in Unity – Tutorial

Duration: 9 minutes

Giving players agency to control the audio’s volume is a key setting expected in most polished games, and this tutorial by Tarodev will help you set that up.

The focus of this tutorial is building a menu that can theoretically be accessed from anywhere in the game. This menu will contain UI elements that allow players to mute the background music, mute the effects, or change the volume of the sounds in general.

Of course, as part of building this menu, you’ll learn how to access the necessary Unity audio tools that allow you to adjust these settings. You’ll also build this sound manager in a way that, as implied above, allows you to effect all sounds in your game. This means it will work across multiple scenes, so you don’t have to fear having many levels as part of your game’s design.

LEARN NOW

Separate Volumes for Music & Sound Effects!

Duration: 13 minutes

What if you want a volume controller like the tutorial above, but want to do things like separate the volumes for music and SFX?

This tutorial by Ricky Dev covers – as stripped down as possible – creating both a menu and sound manager setup that splits audio for music and SFX. The effect is achieved by learning how to use the audio mixers and assigning your sounds to specific audio groups. These groups then allow you to control the volume for specific sets of sounds, allowing you to create dynamic volume controls.

To boot, this tutorial also makes this process very modular. So, for example, if you also had character voice over and wanted to split that into its own group, this setup makes that very easy to do!

LEARN NOW

AUDIO MIXERS In Unity

Duration: 17 minutes

If you’re looking for something a bit slower paced when it comes to setting up volume control menus, this tutorial by Kap Koder is a good one to check.

Like others on this list, this tutorial covers everything you need to set up a volume control menu where the music and SFX are separately controlled. This includes separating things with the Audio Mixer, setting up the UI sliders, persisting the audio settings between scenes, and so forth.

However, this tutorial does take a bit more time to explain things as the menu is developed – particularly with some of the C# coding elements and why certain choices are made. Thus, if you’re a bit less experienced, this slower pace may be the better match for this particular aspect of Unity audio.

LEARN NOW

How to Fade Between Audio Tracks

Duration: 12 minutes

For those who want to create a smoother audio experience, this tutorial by Comp-3 Interactive will teach you the coveted fade-in, fade-out effect.

Particularly when you have ambient sounds or background music, there may come a time when you need to switch the tracks you’re using (as exampled in this tutorial, walking outside from inside). With fade-in and fade-out tricks, you can make sure this switch isn’t jarring, and helps maintain the ambient atmosphere that you may want for your game.

Using primarily C# scripting, this tutorial will show you how to combine volume, loops, and coroutines that allow you to create this fading audio effect. This will be set up to work with any sort of audio as well, so can be applied to many different cases.

LEARN NOW

How to Seamlessly playing music between multiple scenes

Duration: 9 minutes

In this tutorial by CatoDevs – Unity & R Tutorials, you’ll learn how to carry music over from scene to scene.

Scenes in Unity can be fairly isolated from each other. In general, they’re designed to refresh the entire collection of objects available and be almost like a fresh game. While this is perfectly fine in a lot of cases, it can be a pain for audio. After all, what do you do if your scenes need to have a continuous music track?

This short tutorial helps overcome this problem by showing you how to set up a singleton for your audio with the express purpose of bringing music from one scene to the next. Not only does this work in a way that the track doesn’t restart, but you can maintain a consistent volume with a matching UI.

LEARN NOW

Audio Track | Getting Started with Timeline

Duration: 6 minutes

A unique entry on this list, this tutorial by Omar Balfaqih will show you how audio works with the Unity Timeline.

When it comes to composing animations, particularly cutscenes, the Unity Timeline is the go to tool. This tool lets you add various animations, sounds, and cameras to a track. Via this track, you can then arrange these elements to compose your cutscene, choosing the appropriate timings for everything to play.

Using a prebuilt, animated scene as an example, this tutorial will show you specifically how to work with audio. This includes how to adjust placement on the Timeline, how to edit the audio to fit what you need, and even how to deal with your audio sources as it relates to this specific game development task.

LEARN NOW

Unity Audio Tips: Sends, Receives and Effects

Duration: 13 minutes

In this tutorial by Thousand Ant, you can learn to unlock the full power of the Unity Audio Mixer.

Previous entries on this list have focused more so on using the Audio Mixer for volume control. However, the Audio Mixer can also be used as a powerful tool to mix the audio in general for different effects – which can lead to some amazing game atmosphere.

The tutorial in particular shows you how by setting up different groups, and using send and receive signals, you can change the default sound your audio plays. This includes adding things like reverbs, delays, and so forth, all of which can change the game feel of your project. The tutorial also briefly covers how to script a simple random music player, giving you another fantastic tool to add to your audio arsenal.

LEARN NOW

Parting Words

This brings us to the end of our list of best Unity audio tutorials! While adding sound is simple enough, there are a lot of aspects to consider. There are tons of audio effects you’re able to achieve, loads of ways to handle your audio, and even performance considerations to contend with. However, with the tools we’ve presented, we hope we’ve given you a good basis from which to explore adding audio to your game projects.

That being said, we encourage you to dive into even more topics, as audio is as creative as it is technical when it comes to game development. You may also want to learn about topics related to sound design and how these affect your game feel. Regardless, though, we wish you the best of luck, and we can’t wait to “hear” what games you come up with.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Unity Lighting Tutorials – Light up Your Game Levels https://gamedevacademy.org/best-unity-lighting-tutorials/ Mon, 23 Jan 2023 08:06:29 +0000 https://gamedevacademy.org/?p=15380 Read more]]> Lighting is an often overlooked aspect of a game’s look.

Whether a sunny day, quiet night, or dark dungeon, lighting plays a big role in aesthetics. It determines not only what players are seeing, but can add a layer of atmosphere to create a specific mood. After all, would a horror game that has no darkness or sparse lighting be as scary as one with those elements?

Through this article, we wish to explore the topic of lighting, and set you up with the best Unity lighting tutorials available. These tutorials will not only get you familiar with how Unity’s lighting system works, but show you how you can use it for very specific effects.

If you’re ready to light up your worlds, let’s get started.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

UNITY LIGHTING 2020 TUTORIAL For Beginners – Tips, Basics and Settings

Duration: 36 minutes

If you’ve never working with lighting in Unity before, this tutorial by TheUnityGameDev is a great place to start.

The tutorial covers a little bit of everything you might need to know about lighting fundamentals. This includes how to set up your basic lights and adjust them, and how to understand differences between direct and indirect lighting.

In addition to this, though, the tutorial also extensively covers the various light settings available in Unity. You’ll, of course, learn many of the foundations you’ll need for any setup, including settings for the global illumination. However, you’ll also dive into other concepts like baked vs realtime lighting, mixing lighting, and how these concepts can affect your final game’s performance.

LEARN NOW

LIGHTING in Unity

Duration: 16 minutes

For beginners who want to dive more into baked lighting, this tutorial by Brackeys will help you get started.

This tutorial is broken a up into two halves. The first half covers a lot of lighting fundamental theories on how it works. You’ll discover how global illumination plays a role in lighting, how lighting bounces around, how baking works, and so forth – all concepts needed regardless of the lighting you’re using.

The second half of the tutorial covers using the Progressive Lightmapper to light up a scene with different colored lights hitting the same object. This particular tool uses path tracing to more realistically determine how light would bounce around and how that would appear to your camera. You’ll not only learn how to use the Progressive Lightmapper, but also discover many of the settings you can adjust to get the look you want – all with near realtime updates in the editor.

LEARN NOW

3D LIGHTS and LIGHTMAPPING EXPLAINED in Unity 2021

Duration: 14 minutes

Need your baked lighting done quickly? This tutorial by Spectra is right up your alley then.

Like the tutorial above this one, this tutorial covers all the basics of setting up baked light with a lightmap. Whereas the other one focused more so on theory of how light works, this one skips over a lot of that. Instead, it takes a very practical step-by-step approach so you can focus primarily on getting your light set up and various settings that will help improve it as quickly as possible.

To add to this, the tutorial also dives a bit into the justification for lighting and its role in level design. Thus, if you are interested in some theory but as it practically applies to game development, this tutorial is definitely for you.

LEARN NOW

Mastering Unity Lighting Settings & Performance

Duration: 13 minutes

This tutorial by Game Dev Republic does exactly as the title suggests: explains settings available for Unity lighting.

Though knowing how to place and face your lighting in your scene is important, the light settings are where the real magic happens. You’ll get to explore each of these settings very thoroughly, from simply setting the range of your light to working with the lightmapping settings. With each explanation, you’ll also see realtime what each setting does visually, so you won’t have to guess as much when experimenting yourself.

As mentioned, this tutorial does explore performance as well. Using Unity’s own analytics tools, you’ll see with data-based evidence how each type of lighting changes how fast your game is, and consequently be able to make more informed choices for the future.

LEARN NOW

Basics of Lightmapping in Unity 2020.1

Duration: 14 minutes

In this tutorial by UGuruz, you’ll take your first step into lighting in the Universal Render Pipeline.

The Universal Render Pipeline (URP) is a a scripted renderer for Unity that is a bit more powerful in terms of how graphics are rendered compared to Unity’s default pipeline. Besides being able to get more realistic looking games, this pipeline also improves the quality of lighting you can get with your game.

The tutorial focuses particularly on making a scene using URP with lightmapping to create baked lighting. You’ll learn important concepts like setting up UVs correctly, parameters available (including options only available to URP), and optimizing your lighting for mobile. In addition, you’ll also explore ambient occlusion for softer shadows which is made particularly powerful by URP.

LEARN NOW

A Quick Lighting Guide for the URP Pipeline in Unity!

Duration: 9 minutes

While the tutorial above is pretty detailed about using lighting in URP, this tutorial by synty studios focuses on the nitty gritty of just getting your lighting working in that pipeline.

Using a fairly complex scene setup, this tutorial covers how to quickly add URP to your project and common settings you’ll work with to just get your scene lite. This includes concepts like setting up your skybox, or how to adjust things quickly just to make lighting suit your scene.

On top of this, this tutorial also covers a tiny bit about post-processes. Post-processes are a way to apply various filters and graphics tweaks to the final render of the game image. While we have other more in-depth tutorials on this topic further below, this tutorial will show you how to quickly work with these processes to add common effects like bloom and color tints – giving you a whole new way to change the look of your scene!

LEARN NOW

Unity HDRP Lighting Tutorial 2020.3 (Day Time)

Duration: 41 minutes

Similar to our previous entries, this tutorial by Amit Patpatia – Lighting Artist covers lighting as it pertain to another pipeline: the High Definition Render Pipeline (HDRP).

As the name of this pipeline suggests, this is Unity’s graphics rendering pipeline made specifically for high-definition, photorealistic graphics. Not only is it the most powerful of Unity’s pipelines, it vastly changes how aspects of the lighting work within the engine.

The tutorial featured here covers lighting as it works for HDRP fairly comprehensively. Like other tutorials, you’ll of course learn how to set up lights, which settings are available, how to use baked and realtime lighting, reflection & refraction, and so forth. However, this tutorial also covers HDRP specific issues related to workflow so you can make sure you’re getting the most out of this heavy duty pipeline.

LEARN NOW

2D Lights and Shadows in Unity 2019!

Duration: 8 minutes

Created by Unity itself, this tutorial dives into lighting for 2D games.

While previous tutorials have focused heavily on 3D graphics and all the great things you can do for them, you can do dynamic lighting for 2D in Unity thanks to the Universal Render Pipeline. With URP setup for your project, you can extend beyond default global lighting and add a variety of cool light and shadow effects previously not available.

The tutorial starts off by getting you set up with URP properly as is needed for 2D games specifically. You’ll then get to explore a variety of new lights offered – including spotlights, directional lights, and freeform lights. With these new lights, you’ll learn to adjust various properties to create specific lighting effects. Some of the things you’ll master include adding shadows under trees, creating sunshafts, and more, all in ways that work regardless of your specific camera view.

LEARN NOW

Octopath 2D Sprite Shadows And Lighting

Duration: 3 minutes

For advanced users out there, this short tutorial will show you how you can light games where you combine 2D and 3D game graphics.

Created by Allen Devs, this tutorial focuses on showing you how to improve your lighting and shadows to get a similar look to the game Octopath. This is primarily achieved through a few different methods. You’ll first explore the advanced topic of creating a shader with C#. While not specific to lighting itself, shaders do affect how light and shadow interact with your objects. As such, it is an important topic to learn, even if beyond the scope of this list.

After this, you’ll get to explore other fixes needed to create the proper effects, including how to adjust your shadows, how to adjust your environment’s lighting, and so forth. On top of this, you’ll also briefly work with post-processing effects until the final render is achieved – teaching you another valuable skill for other tutorials on this list!

LEARN NOW

REALISTIC LIGHTING in Unity!

Duration: 14 minutes

Have realistic graphics in need of realistic lighting? This tutorial by Sykoo has you covered then.

Assuming you’ve already covered the basics a billion times over at this point, this tutorial focuses on just quickly relating the best way to set up a realistic lighting look for your scene using, primarily, real-time lighting. You’ll cover quite a bit about which light settings work best for realism, where it’s often best to place lights, how to manipulate lights for your specific scene, and so forth.

On top of this, and similar to other tutorials, you’ll also cover the very basics of post-processing and learn those specific settings as well that will best bring about the realistic look. While not the most in-depth of tutorials here, given the popularity of realistic lighting, this is still a great one to check out even just for the sake of adding to your personal knowledge base.

LEARN NOW

Create a DAY and NIGHT Cycle in Unity

Duration: 25 minutes

With this tutorial by Zenva, you’ll create a day-night cycle with actual lighting for the sun and moon.

Whereas previous tutorials have been rather static in terms of their scenes, this tutorial will serve as the reminder that Unity is a game engine. As such, our lighting is not limited to a single spot in our level, but can be moved about via script or other similar mechanisms.

The short mini-course will show you how to create a sun and moon effect that seem to rotate around the level from horizon to horizon. This will be implemented along with an adjustable time scale so that, as time passes in your game, the lighting will mimic the cycle appropriately. On top of this, the tutorial also covers how to do things like add different gradients of color to the mix that also change with the time. In this way, you can also get that nice color match for dawn, noon, evening, and night!

LEARN NOW

Lighting And Post-Processing Low Poly Scene

Duration: 13 minutes

In this tutorial by LMHPOLY, you’ll learn the ins and outs of lighting for low-poly models.

To start this tutorial off, you’ll learn tips and tricks for setting up your lights in general. This includes things like where to place them, what settings to use, and also how to bake with lightmaps. Of course, the focus here will be specifically oriented for low poly models and how to achieve the best look for this particular art style.

The other half of this tutorial, though, takes a deep dive into post-processes. As covered earlier, post-processes are what allow you to apply “filters” to the game’s final rendered look. Unlike previous tutorials, though, this tutorial takes a more careful approach and covers a number of different settings, such as aperture, depth of field, chromatic aberration, grain, and exposure. Though you’re left free to experiment and find the look you want, the tutorial serves to demonstrate how lighting and post-processing can be companions in creating your game aesthetic.

LEARN NOW

Unity 2D lighting & post processing effects

Duration: 7 minutes

With guidance from Game Dev Republic, this tutorial covers 2D lighting, post-processing, and tips to make cool-looking scenes.

Of the tutorials on this list, this is one very “light” on the topic of adding lights to the scene itself – featuring really only a single directional light that works in realtime. However, the tutorial makes up for this by taking a much more thorough look into the world of post-processing.

Through this video, you’ll explore a lot of different settings available for post-processing. Of course, you’ll learn a few things already covered on this list, such as adding things like bloom or depth of field. However, the tutorial also covers new things, such as color grading for specific materials versus the entire scene. Altogether, you’ll learn numerous tricks for combining post-processing that works even with minimal lighting and allows you to bring out the best in your 2D graphics.

LEARN NOW

Level Design for Beginners

Duration: 1 hour

Though this tutorial talks about lighting the least, we did want to include it as a bonus resource.

Created by Zenva, this premium course covers principles of game design for creating levels. This includes concepts related to environmental storytelling, making considerations for the genre of your game, and more.

As this is a best Unity lighting tutorials list, though, there is obviously something about lighting here. In this case, you’ll learn quite a bit about how lighting works not only for the environment, but how it guides the player through your game. This includes things like subtlety hinting where players should go, and similar. Thus, if you want to also use lights to improve your levels design-wise, this course can help out in that regard!

LEARN NOW

Parting Words

As we come to a close, we hope you’ve found a tutorial you like from this best Unity lighting tutorials list. Lighting is a huge topic of study that goes beyond just how to implement it in Unity. As such, we encourage you to not only experiment with your lighting, but find out good rules of thumb for how to use it.

Remember, though, that lighting can be extremely powerful! It can take your cutscenes and levels to a new height, and make memorable experiences for your players they’ll never forget. It can also help you emphasize exactly what you’re hoping people will feel at certain parts, or even be used to simply provide player guidance in terms of the design.

Whatever you need to use lighting for, though, we wish you the best of luck in utilizing it for your game projects.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Best Unity Shader Graph Tutorials – Game Development https://gamedevacademy.org/best-unity-shader-graph-tutorials/ Sun, 22 Jan 2023 08:05:45 +0000 https://gamedevacademy.org/?p=15374 Read more]]> These days, graphics for video games are pretty important – from AAA hits to even the smallest indie video games.

When creating art assets, there are a lot of things to consider, such as art style, poly counts, and so forth. However, there is another important factor that affects all games: how these graphics are actually rendered by the computer. While there is a lot to the topic of rendering, one that people will interact with the most during the development process are shaders. Shaders are useful for a lot of things, from cool effects to simply determining how light interacts with a specific graphic.

However, when it comes to programming, most people don’t really want to deal with the tedium of making a shader. In the case of Unity, though, the process of setting up shaders has been made simple with its Shader Graph tool. In this article, we’re going to explore the best Unity Shader Graph tutorials so you can not only learn how to use it in the first place, but get specific effects with it.

Let’s dive in!

Note: This list is intended for individual learners. If you’re an educator looking for new classroom resources, we recommend checking out Zenva Schools.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

About Shader Graph

Though we know you’re eager to get to the tutorials, we first want to take a moment to discuss what Shader Graph is. This way, if you’ve never heard of Shader Graph, you’ll go in with some knowledge at your fingers.

What are Shaders?

Let’s first talk about shaders themselves. Put simply, shaders are simply programs or scripts that determine how each pixel on a screen is rendered based on the settings for that specific shader. You can think of shaders almost like photo filters, though in this case instead of a photo, we’re working with complicated meshes, lighting, and similar data. Nevertheless, shaders are able to calculate all this graphics information, and then alter the original pixel data to come out with something entirely new.

So, in short, shaders are simply ways that let us alter how our graphics look programmatically.

What is Shader Graph?

As mentioned previously, Shader Graph is Unity’s solution to working with shaders. Instead of having to code things from scratch, Unity gives you a convenient canvas (i.e. “graph”) that allows you to add specific shader nodes to it. These shader nodes are each designed to do something different, such as change overall color, add noise, or alter specular lighting appearance. There are over 200 nodes with Shader Graph, so the options are endless.

Nevertheless, with Shader Graph, you’re able to connect nodes up to combine each of these effects, ultimately giving you a new look for your graphics.

Shader Graph fundamentals in Unity

Duration: 36 minutes

To start things off with – especially if you’re new to shaders and Shader Graph – we recommend diving into this tutorial by PabloMakes.

This tutorial focuses less on hand-holding and more on giving you the fundamentals by showing you some of the most common examples beginning developers use Shader Graph for. This includes aspects such as adding noise maps to things, using it for UVs and textures, working with reflections and distortions, and similar.

This learn-by-doing approach also explores key things you’ll need to know regardless of how you use Shader Graph – including how to connect nodes, various common settings you can adjust and so forth. While this doesn’t show off the full power of Shader Graph in comparison to regular materials very much, it does give you a fantastic taste of some of the things you can do with Shader Graph and lets you get familiar with the tool.

LEARN NOW

How to Make Your First Shader Graph

Duration: 25 minutes

For those who like a very thorough, hand-holding approach to their learning, this tutorial by Daniel Ilett is a good place to start.

Rather than rushing you into several shaders, this tutorial takes its time to walk you step-by-step and explain everything that’s going on in detail. This includes everything from how to set up your Shader Graph, how to work with the nodes, and even details on how the settings with each node work and can be manipulated.

As the title suggests, you’ll also get experience in how to make your very first shader – one that just has a simple texture applied to it. Similarly, though, the approach is methodical so you gain a greater understanding of every step taken to get to your final product. Thus, this tutorial ensures that you can repeat these steps over and over again with fantastic foundations that are applicable to every shader you might create in the future.

LEARN NOW

Make Awesome Effects with Shader Graph in Unity!

Duration: 14 minutes

Created by Code Monkey, this last absolute beginner’s level tutorial on Shader Graph covers the basics plus a few extras that will help you better use shaders in your games.

Similar to the other beginner tutorials on this list, you will start by learning the foundations of Shader Graph: how to set it up with the Universal Render Pipeline, how Shader Graph and its nodes work, and likewise. However, this tutorial does go a bit more in-depth into how you can combine different nodes to create really awesome and unique effects – all depending on how you hook your nodes up to each other.

This tutorial also goes into the topic of C# scripting. In this case, you’ll learn how to combine input detection with access to certain material properties. In so doing, you’ll discover how you can alter your shaders in various ways with coding, which can of course be used in scripts for your games in real-time!

LEARN NOW

Unity Shader Graph Tutorials

Duration: 15 hours, 48 minutes

This immense tutorial series by Gabriel Aguiar Prod. is fantastic if you’re past the beginners point for Shader Graph or just want to, you know, create really awesome shader effects.

Spread across 60+ videos of content, this series features a variety of step-by-step tutorials, each focused on creating a specific effect. While we can’t name every effect covered, some of the highlights include: lava, ice, warp effects, lasers, clouds, weapon attacks, portals, fire effects, rock and moss textures, and more.

Rest assured that every tutorial covers all the nodes you’ll need to render these effects. As such, this series makes sure you can quickly start using Shader Graph for your own projects however you might choose to do so.

LEARN NOW

Stylized Water Shader Graph

Duration: 21 minutes

Does your game project need any water? Well, this tutorial by Binary Lunar is great for that topic.

While Shader Graph can be used for many effects, one of the most common things you’ll see every developer use shaders for is water. Shader Graph gives you unprecedented power to simulate water with its various liquid mechanics. This applies from extremely stylized water to the most realistic in-game water you can imagine.

The tutorial covers a variety of different aspects you may want to consider when rendering a water effect. This includes issues related to replicating refraction, simulating foam, adding waves, and even setting up scenes to make best use of your water. Though you can experiment beyond this, this tutorial will show you just how convenient Shader Graph can be for liquid effects.

LEARN NOW

Dissolving Ground Trail Effect in Unity using Shader Graph

Duration: 17 minutes

This tutorial by AE Tuts is unique as it not only shows you a cool effect you can make with Shader Graph, but teaches you how to add this effect as a trail to a player.

While many of the previous tutorials have focused on simple things like changing an object’s color, you can take that many steps further. In the case of this tutorial, you’ll learn how – just using shaders – you can make an object seem to dissolve, particularly the floor as will be taught here.

As mentioned, though, this tutorial goes beyond that and teaches you how you can access Unity’s particle system during the set up process of your shader. In so doing, you can learn some more intermediate techniques you can apply to your creation to create the ultimate custom effect, whether you want a dissolving trail behind your player or something else entirely.

LEARN NOW

Toon Shading – The EASIEST WAY! Unity3D URP Shadergraph Tutorial

Duration: 12 minutes

Most of the tutorials on this list cover effects, which is a popular use for Shader Graph and comes with a lot of cool factor. However, as the name “shader” implies, you can also use Shader Graph to simply change how an object is shaded in a game. By this, we mean how do shadows appear when the object interacts with the light.

This short tutorial by Léo Chaumartin focuses exactly on this subject. Over the course of just 12 minutes, you’ll learn how to create a toon shader which features sharp edged shadows. These styles of shaders are immensely popular for cartoon-styled games, and also demonstrate just how you can change how “lighting” works in your game.

Even if toon shading isn’t your speed, the foundations taught here will at least enable you to start looking for your own styles of shading to use!

LEARN NOW

Outlines on One Object in Unity URP Shader Graph with Edge Detection!

Duration: 1 hour, 9 minutes

If you’re more of an advanced developer, this tutorial series by Ned Makes Games covers using scripting and Shader Graph to add outlines to objects in ways that should pique your interest.

Though this sounds easy enough, these tutorials actually go very in-depth into a lot more theoretical concepts that can come with shaders. Instead of just using Shader Graph, these tutorials include actual C# scripting for shaders in combination. As such, you will not only learn Shader Graph, but some of the logic behind how shaders work from a programming perspective.

In terms of the topics covered, you’ll learn things like how to detect object edges, how to deal with occlusion, how to alter your outlines for different looks (including just changing colors), and even how to tweak your shaders for performance purposes.

LEARN NOW

Unity Shader Graph 2D

Duration: 3 hours, 30 minutes

Although previous tutorials on this list have had an extreme bias for 3D games, this series by Binary Lunar covers how Shader Graph works for 2D games.

While Shader Graph does not operate too differently between 3D and 2D art assets, there are still quirks to consider. As such, learning some of the effects you can do for 2D specifically can greatly expand your repertoire for using shaders in general.

This series lets you explore these various quirks by simply just building some awesome effects. These effects include water (of course), dissolve effects, glows, space objects, lasers, wind effects, and much more. There are even a few on simpler ones, such as one that focuses on automatically pixelating your 2D assets, so there’s plenty of effects to discover.

LEARN NOW

How to make 2D GLOW in Unity!

Duration: 16 minutes

In this tutorial by Brackeys, you’ll learn glowing isn’t just for 3D games!

As the title suggests, the focus on this one is simply making a cool glow effect that works for 2D games using Shader Graph. However, instead of making the object as a whole glow, this tutorial teaches you how to alter your sprite sheets so that only specific areas are effected. Thus, as this tutorial shows, you make make very cool combinations where only part of a character’s costume glows.

In addition to this, the tutorial also covers how to adjust your lighting for the scene as a whole to bring out the glow’s maximum effects. Thus, you not only learn how to make this shader, but how you can do other things outside Shader Graph to enhance the game feel you’re going for.

LEARN NOW

How To Use All 200+ Nodes in Unity Shader Graph

Duration: 1 hour, 21 minutes

No best Shader Graph tutorial list would be complete without this immense tutorial by Daniel Ilett.

Shader Graph has over 200 nodes available for altering your output. This isn’t even counting the fact that many of these nodes have multiple settings you can adjust at your leisure. Suffice it to say, previous tutorials on this list only scratched the surface of what was available.

As the title suggests here, this tutorial sets out to do one thing: cover what every node in Shader Graph does. While there is no expectation you’ll memorize every node – since some are way more useful than others – this tutorial is fantastic for discovering new nodes you didn’t know exist. Perhaps you’ll find that one special node you need to create a particular effects. Regardless though, learning all the nodes gives you something to store away in your memory banks for a rainy day.

LEARN NOW

Conclusion

And there we have it – what we consider the best Unity Shader Graph tutorials available. As the last tutorial shows you, though, we’ve only scratched the surface here. With so many nodes available, the number of effects you can create are endless, and there are tons of effects we didn’t even get a chance to put on this list.

However, there is no contest that Shader Graph is a fantastic tool. It gives you the ability to change your graphics in profound, easy-to-use ways without you having to touch a single line of code. It’s also available for both 2D and 3D games, so you can apply it no matter your game’s particular art style.

We do encourage you to experiment once you’re more familiar with Shader Graph, and we can’t wait to see how you use it in your games!

Are you an educator? Try out Zenva Schools – a K12 platform of online courses focused on coding for the classroom. Featuring tons of features from classroom management to reporting, Zenva Schools is a one-stop shop for teaching topics like game development.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
Unity Animator Tutorial – Comprehensive Guide https://gamedevacademy.org/unity-animator-tutorial/ Mon, 19 Dec 2022 08:41:33 +0000 https://gamedevacademy.org/?p=5277 Read more]]> Tired of static assets? What about adding some animations to your games?

Well, for Unity developers, you’ve come to the right place.

In this tutorial, we will explore how to use animations in a scene.

Let’s jump into it!

Project Files & Requirements

The scripts for this lesson can be downloaded here

This tutorial is a good step for those who have read the tutorial on creating animations, which you can view here. However, no prior knowledge of animation is required.

That being said, it is assumed you have some basic knowledge of Unity, which you can learn via other tutorials or online courses such as the Unity Game Development Mini-Degree. If you’re an educator, you can also try out Zenva Schools which offers complete beginner-friendly courses alongside other fantastic tools for teaching in the classroom.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Setting up the project

Open up Unity and create a new project. Create a folder called “Scenes” and save the current scene in that folder.

Go to Assets -> Import Package -> and select the “Characters” package.

Uncheck the first person character since we won’t be working with that.

Now make a plane for the character to stand on. Next, make some cubes and ramps for our character to run and walk on

.

This is optional but, go ahead and drag in the “ThirdPersonController” into the scene. Play and look how the character moves. We are going to build, from scratch, a character that moves similar to this.

Once you have got a feel for how the character moves, ThirdPersonController is no longer needed and you can delete it.

The Animator

Navigate in your project files to Standard Assets -> Characters -> Models and drag in the “Ethan” model.

Then create a folder called “Animation”.

Right click and go to  Create -> “Animator Controller”.

Name it “Ethan”. Drag our new Animator Controller onto the Ethan model.

The Animator Controller allows you to assign multiple animations to a model. For humanoid characters, such as ours, it requires something called an “Avatar”. Click on the circle next to the Avatar field and find the “EthanAvatar”. Lets have a look at the Avatar.

Click “Configure Avatar”.

As you can see, the Avatar is just a way for Unity to find and configure the bones in the model.

Press done and go back to the Ethan model. Let’s look at some of the settings in the Animator component.

The “Apply Root Motion” boolean determines if Unity will use the movement in the animation or a script. For example, say I have a script that makes my character move forward. I have an animation attached of the character running in place. Since the script is moving the character not the animation then I would want Root Motion set to false. However, as we will see soon, we want to enable Root Motion in this case. With “Update Mode” you can determine how you want your animations to play. Such as with physics, with a fixed speed, or just normal. Culling mode allows you to determine if you want to keep animating even off screen. With the Ethan model selected, navigate to the “Animator” tab.

Here is where we add in the animations that will effect our model.

States

In your Project tab set the filter for animations.

Look for “HumanoidIdle,” “HumanoidWalk,” and “HumanoidRun.”

Drag these three into your Animator tab. Now there are three new boxes in our tab, those are the animations known as State Machines. Also, notice how one of the boxes is orange.

The orange one is the first one you selected in your Project tab. That is known a “Default State”. We want the “HumanoidIdle” to be the Default State. To do this right click on “HumanoidIdle” and select “Set as Layer Default State”.

See how the Default State has an orange arrow coming from the box that says Entry. This means that as soon as the game starts it will go to the Default State. Press play and see what happens. Our model is idling!

That is pretty neat, but it makes for a really boring game. We want our character to be able to run and walk around the scene. To do that, right click on the Default State and select “Make transition”. Then click on the “HumanoidWalk” state.

Now press play and look what happens. Ethan idles for a bit then starts walking.

Now do the same thing for the run state. Then press play and see what happens. Our player idles, walks, then runs.

Parameters and Transitions

We have our model animating but it lacks control. It idles and runs without us doing anything. The way we add control is through Parameters. Parameters are variables that are defined within the animator that scripts can access and assign values to, this is how a script can interact with the Animator. There are three types: Int (or Integer), Float, Boolean, and Trigger.

All of them are pretty self explanatory except for Trigger. A trigger is like a boolean but as soon as it is set to true it immediately goes back to false. We will realize it’s usefulness soon. For now make a float parameter and call it Speed.

Then click on the idle to walk transition and set the condition to be if Speed is greater than 0.5. This means that it will only transition if Speed is greater than 0.5.

Then click on the walk to run transition and set the condition to if Speed is greater than 0.9. Now play, increase or decrease the Speed parameter to see what happens.

Okay not too bad but could use some tweaking. First off I am going to go to each transition and uncheck “Has Exit Time,”

with this enabled the transition would go through the whole animation before transitioning. Which means there will be a delay if the player presses the run key. Second, make two other transitions (disabling Has Exit Time of course), one going from run to walk, and then walk to idle.

Set the Run to Walk condition to Speed is less than 0.9 and the condition of Walk to Idle to Speed is less than 0.5. Okay now that we have that done let’s look at the transition settings. Notice how you can preview the transition?

The blue section is where and how long the transition will be. You can change at what point a certain clip will transition.

This can be used to make your transitions look more realistic. Open up Settings on a transition.

Exit time is how long before the transition starts to exit. With Fixed Duration enabled we can use the blue marker for transitioning. Transition Duration is pretty self explanatory, the length of the transition! Interruption Source is pretty interesting. If a transition’s condition becomes false as it is transitioning, it has been interrupted. When Interruption Source is set to None it can be interrupted be the Any State (which we will look at later). When set to Current State it will go through the transition then be interrupted. Next State runs the next transition then can be interrupted. Current State Then Next State runs the current transition then the next transition before being interrupted. Next State Then Current State is basically the reverse, if an interruption occurs it runs the next transition then the current transition. It doesn’t matter what you set these settings to because we will actually not be using it!

Blend Trees 1D

This locomotion system works but it isn’t very modular. We can’t add turning left or right very easily. A better and cleaner way to do this would be through Blend Trees. Blend Trees are a way to blend multiple animations together smoothly in varying degrees. To make a Blend Tree right click in the Animator and select Create State -> From New Blend Tree. Name it “Locomotion” or “OnGround”.

Double click on it, add three motion fields and put the three animations in it idle, walk, run.

The thresholds are already setup for us but if you want to customize them uncheck “Automate fields”. Basically, it is everything we have already done but in a nicer format. When the Speed parameter gets over 0.5 the character walks, when Speed equals 1 the character runs. Go back to the Base Layer and delete the three other states.

Then make a transition (unless it does it for you) from entry to our Locomotion Blend Tree.

Now play and see what happens. Looks good, if you notice it blends the walk and run animation together if Speed is between 0.5 and 1.

Making Our Character Turn

So our character can run, walk, and idle but it isn’t very exciting. Unless you have a game where the character only runs forward (which, who does?) it isn’t even remotely useful. We need our character to be able to turn left and right (obviously!). In order to do this go back to our Locomotion Blend Tree and set the type to “2D Freeform Cartesian.” A Blend Tree has five different types of blending modes: 1D, 2D Simple Directional, 2D Freeform Directional, 2D Freeform Cartesian, and Directional.

We have already looked at 1D. 1D uses just one parameter to check with, while any of the other types require two. 2D Simple Directional is if you need something slightly more complicated than 1D. An example would be if you just need Walk Forward, Walk Right, or Walk Left motions. 2D Freeform Directional is slightly more complicated. It would be able to handle, Walk Forward, Run Forward, Walk Right, Run Right etc. 2D Freeform Cartesian adds another level of complexity to the mix. It allows Run, Walk, and Turning. Before we do anything though we need to create a new float parameter called “TurningSpeed” and put it in the other parameter slot.

Now these next steps may not make much sense but stick with me and hopefully I can explain it well enough. Add twelve more motion slots. Look for and assign these animations to it in this order:

“StandQuarterTurnRight”, “StandHalfTurnRight”, “HumanoidWalkRight”, “HumanoidWalkRightSharp”, “HumanoidRunRight”, “HumanoidRunRightSharp”, “StandQuarterTurnLeft”, “StandHalfTurnLeft”, “HumanoidWalkLeft”, “HumanoidWalkLeftSharp”, “HumanoidLeftRight”, and “HumanoidRunLeftSharp.”

Then assign the values to look like the following:

Your graph should look like this:

Okay, hopefully you are still with us after that huge list of unexplained tasks. If you did everything you can now play and change the values for Speed and TurnSpeed to see what happens.

Pretty neat! But why does it do that? To answer this you need to understand how 2D Freeform Cartesian works. Think of it like a graph. The Speed parameter is the x value and TurnSpeed is the y value. If the both values equal 0 then the player is standing still. If TurnSpeed is -1 the character turns left. If it is 1 the player turns right, all while blending between “StandQuarterTurnRight” or “StandHalfTurnRight.” If Speed equals 1 the player runs, 0.5 and the character walks. If TurnSpeed is 1 and Speed is 1 then the player runs right. If both equal 0.5 the player walks right. If you understand that then you should understand why we set the values to be what they are. Look at this graph for extra visualization:

Hopefully, this has cleared up most questions about 2D Freeform Cartesian. If not don’t worry! Just think about it, it’ll come to you.

The “Jumping” sub-state machine

In order to make our character jump we need a few things. A jump up pose, a fall pose, a landed pose, a way to check if the player presses the jump key, and a way to check if we hit the ground. I am going to do the last two first. Create a new trigger called “Jump”.

And then create a boolean called “grounded”. Okay that is done now we can move on. Filter search for the following animations “HumanoidCrouchIdle” (this is our landed pose), “HumanoidFall”, and “HumanoidJumpUp”.

Before we drag those in we need to change something. If you preview one of the animations you will notice an unwanted twitch.

To fix this click edit, then set the motion to be only one frame long.

But we still can’t drag them in yet! We first need to create something called a Sub-State Machine. A Sub-State Machine is a bunch of motions put together that act as one. This is a good thing to use for jumping actions since a jump action isn’t really just one action but a bunch of them put together. Right click in the animator and press “Create Sub-State Machine”.

Name it jump. Now drag all our Jump poses onto the new Sub-State Machine.

Now we can start constructing our Jump action. Make a transition from Any State to the JumpUp pose. The Any State is a very useful tool. It will transition into a motion, if the condition is true, regardless of where that motion is. Set the condition to be our Jump trigger. Then make a transition from JumpUp to Fall. Make a Fall to Crouch transition but remember we only want it to transition if it hits the ground. Set the condition to be if grounded equals true and uncheck Has Exit Time. Where do we transition to after this? From crouch into the Exit state. When something transitions into the Exit state on a Sub-State Machine it will go back to the Entry state in the Base Layer.

Okay, we have our Jump action setup! Although we still need to add physics, play and tweak the settings to get the look you’re after.

Scripting Our Animator

Now we come to the last and arguably most important part of this lesson, scripting. We have already seen how pretty much everything in the Animator is controlled by parameters. So our script should control those parameters. Before we start we need a capsule collider and a Rigidbody on our character. Set the capsule collider to roughly surround our character.

Then create a new script called “PlayerController”. The way we control parameters through script is first getting access to the Animator:

private Animator thisAnim;

Start (){
    thisAnim = GetComponent<Animator>();
}

Then write something like the following command:

thisAnim.SetTrigger ("Jump");

Let’s think about what we need to do. First, we need a forward and backward input:

void Update (){
var v = Input.GetAxis ("Vertical");
thisAnim.SetFloat ("Speed", v);
}

Use the Unity Input axis Vertical, which by default is the up and down arrows, then put it in a variable and assign that variable to the parameter “Speed”. The Input settings can be configured here:

Next we need a turning input:

void Update () {
	var h = Input.GetAxis ("Horizontal");
	var v = Input.GetAxis ("Vertical");
	thisAnim.SetFloat ("Speed", v);
	thisAnim.SetFloat ("TurningSpeed", h);
}

We use the axis Horizontal, which by default is the left and right arrows, just like we used the Vertical axis only this time assigning it to TurningSpeed. Play and see what happens.

Okay our character does a face plant. To fix this, constrain our rotation on the X, Y, and Z axis.

Now play and see what happens.

Wow, just wow. It looks really good! Now we just need to add the jumping input. In order to jump we need a Rigidbody to act force upon, trigger the Jump parameter, check to see when our character lands, and set “grounded” to be true if the player does land. First, we get the Rigidbody and trigger jump with the input button “Jump”:

private Animator thisAnim;
private Rigidbody rigid;
public float JumpForce = 500;

void Start () {
	thisAnim = GetComponent<Animator> ();
	rigid = GetComponent<Rigidbody> ();
	}
 void Update () {
         var h = Input.GetAxis ("Horizontal");
         var v = Input.GetAxis ("Vertical");
 
         thisAnim.SetFloat ("Speed", v);
         thisAnim.SetFloat ("TurningSpeed", h);
         if (Input.GetButtonDown ("Jump")) {
             rigid.AddForce (Vector3.up * JumpForce);
             thisAnim.SetTrigger ("Jump");
         }
}

“Jump” by default is set to the space bar in the Input Manager. Then we raycast downwards to see if we have hit the ground while changing the value of “grounded”:

if (Physics.Raycast (transform.position + (Vector3.up * 0.1f), Vector3.down, groundDistance, whatIsGround)) {
	thisAnim.SetBool ("grounded", true);
	thisAnim.applyRootMotion = true;
} else {
	thisAnim.SetBool ("grounded", false);
}

This part needs a float, for how far down check for ground, and a layer mask, to define what ground is. A Layer Mask is a way to group objects, kind of like tags. Declare those here:

private Animator thisAnim;
private Rigidbody rigid;
public float groundDistance = 0.3f;
public float JumpForce = 500;
public LayerMask whatIsGround;

This is the full script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {
	private Animator thisAnim;
	private Rigidbody rigid;
	public float groundDistance = 0.3f;
	public float JumpForce = 500;
	public LayerMask whatIsGround;

	// Use this for initialization
	void Start () {
		thisAnim = GetComponent<Animator> ();
		rigid = GetComponent<Rigidbody> ();
	}
	
	// Update is called once per frame
	void Update () {
		var h = Input.GetAxis ("Horizontal");
		var v = Input.GetAxis ("Vertical");

		thisAnim.SetFloat ("Speed", v);
		thisAnim.SetFloat ("TurningSpeed", h);
		if (Input.GetButtonDown ("Jump")) {
			rigid.AddForce (Vector3.up * JumpForce);
			thisAnim.SetTrigger ("Jump");
		}
		if (Physics.Raycast (transform.position + (Vector3.up * 0.1f), Vector3.down, groundDistance, whatIsGround)) {
			thisAnim.SetBool ("grounded", true);
			thisAnim.applyRootMotion = true;
		} else {
			thisAnim.SetBool ("grounded", false);
		}

	}

}

Make sure WhatIsGround is set to Default. Play and see what happens.

Yes! It looks amazing!

Conclusion

Wow! We have covered a lot, and hopefully by now you have a good understanding of the Unity Animator! The Animator was made to be rather robust and allow us to add all those moving bits that make games engaging. Of course, though, you can take your skills even further. For example, maybe you could learn about adding footsteps along with your animated character? 😉

Of course, you can also explore more about making games in general through other Unity learning resources. Even schools can take advantage of platforms like Zenva Schools to add Unity to the classroom.

Either way, I hope this tutorial was helpful and that you get an understanding of how complicated but fun the Unity Animator is.

Keep making great games!

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
A Guide to Handling Huge Open Worlds in Unity – Part 1 https://gamedevacademy.org/how-to-handle-huge-worlds-in-unity-part-1-deactivating-distant-regions-to-improve-performance/ Sun, 18 Dec 2022 17:49:55 +0000 https://gamedevacademy.org/?p=6014 Read more]]> Have you ever wondered how open worlds in video games work performance-wise?

In this tutorial series, we’re going to explore just how video games deal with huge worlds and make the best use of the processing power and memory available to the computer.

For this first part of our huge world tutorial, we’re specifically going to focus on how to process terrains, split them, and write scripts that will hide them when the player is too far away. In Part 2, we’ll circle back to how to deal with other objects, like trees, and also cover fog so you can easily hide your environment manipulations.

If you’re ready to learn the tools necessary for building open-world environments, let’s get started!

Source code files & Requirements

You can download the tutorial source code files (the Standard Assets folder was not included to reduce the file size)  here.

Additionally, please note that this tutorial does assume you already know the basics of Unity and C#. If this is your first time venturing into Unity, we recommend pausing and taking some beginner-friendly courses first to explore the fundamentals you’ll need to jump in.

If you’re an educator, you can also consider trying out Zenva Schools. Zenva Schools is an online learning platform aimed at K12 institutions. It comes with a variety of features for classroom management, and also offers many beginner-friendly courses on Unity as well.

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

Creating the world

Before starting the tutorial, create a new Unity project.

There are different ways to create the world map of your game. Since the focus of this tutorial is on how to handle such world map, and not on how to create it, we are going to use an automated tool to create the map.

The tool we are going to use is called L3DT. This tool allows you to generate huge world maps which you can import in Unity later. Start by downloading and installing the program. Then, open it and select File -> New project.

L3DT with File menu open

We are going to create a Designable map. Select the map size you prefer.
In this tutorial, I’m going to generate a map with size 512×512. You can leave the other parameters in their default values.

L3DT Wizard with Heightfield size settings open

In the calculation queue window, select all maps to be created. In the end, we are only going to use the height map and the texture map, but generating the other maps will add information to the texture map in the end. For each map, you can leave the default parameters.

L3DT Wizard with Calculation queue settings open

In the end, l3dt will generate a map like this one.

World generation provided by L3DT

What we need to do now is exporting the height map and the texture map, so that we can import them later in Unity. In order to export the height map, select the heightfield tab, then right-click on the map and select Export. Unity only imports RAW, so we need to export it in this format. I’m going to create a folder called L3DT in the Assets folder of my Unity project, so that I can export the L3DT files there.

L3DT Wizard with Export Map window open

The texture map can be exported in a similar way. Select the texture map tab, right-click on the map and select Export. We are going to export it in the PNG format.

L3DT Wizard Export map options to export texture

Importing the map in Unity

Now, let’s import this map in Unity. First, open the Unity project you have created. In this project add a new Terrain object (right-click on the hierarchy and select 3D Object -> Terrain). This will create a new object with the Terrain component.

Terrain object in the Unity Inspector with Terrain Component open

Now, we are going to import the height map and the texture map into this terrain. In order to import the height map, select the terrain settings, go to the Heightmap section and click on Import Raw. Then, select the height map you have export from L3DT. It is important to set the Terrain Size to be the same as the L3DT map size (512×512). The size in the Y axis defines the height of the mountains, so you can try different values until you find the one that looks better in your game. I’m going to use a Y size of 100.

Import Heightmap window in Unity with 100 set for the Y

In order to import the texture map, you need to select the Paint texture option in the Terrain component. Then, click Edit textures to add a new texture.
Select the exported L3DT texture and set its size to be the L3DT map size (512×512). However, notice that, due to different coordinate systems between L3DT and Unity, the Y size must be negative (-512).

Add Terrain Texture window in Unity with world selected

After doing so, you should have your map imported in Unity. Now, our next step will be to slice this map into tiles.

World deformation in Unity game scene

Slicing the map into tiles

As I mentioned, we are going to activate the map regions that are close to the player, while deactivating those far away from it. In order to do so, we need to slice our world map into tiles. Instead of writing our own code to slice the map, we are going to use a solution available online.

Here you can download a Unity package to split terrains. After downloading it, just open it and it will import itself into your project. This will add a tab called Dvornik in your Unity project. By selecting it you can split the create terrain into four tiles.

However, once you do this, you will see that the terrain texture is being repeated for each tile.

Unity map object with tiles sliced

You can fix that by clicking on edit texture and adding the following offsets for the tiles:

  • Terrain 0: offset x = 0, offset y = 0
  • Terrain 1: offset x = 0, offset y = 256
  • Terrain 2: offset x = 256, offset y = 0
  • Terrain 3: offset x = 256, offset y = 256

We can repeat the process for each created tile, further dividing the terrain into sixteen tiles. Again, after splitting each tile, we need to adjust the offsets accordingly. However, instead of adding an offset of 256, now we need to add an offset of 128. For example, the offset of the new tiles created from Terrain 1 are:

  • Terrain 1 0: offset x = 0, offset y = 256
  • Terrain 1 1: offset x = 0, offset y = 384
  • Terrain 1 2: offset x = 128, offset y = 256
  • Terrain 1 3: offset x = 128, offset y = 384

In the end you should have a map with 16 tiles. Now that we have our world tiles, let’s start coding the script which will activate and deactivate terrain tiles according to the player proximity.

Deactivating distant tiles

We want our game to keep track of the player position and, when the player is far away from a given tile, to deactivate this tile from the game in order to improve performance. This way, this tile won’t be rendered, and our game won’t be wasting CPU and memory on such distant tiles.

The first thing we need is creating a HideTilesScript. This Script will be added to the Player object, and it will keep track of the distant terrains in order to hide them. In order to do so, we need the following attributes in this script:

  • tileTag: the tag of the tile objects, so that we can identify them.
  • tileSize: the size of each tile (128×128 in our case).
  • maxDistance: the maximum distance the player can be from the tile before it is deactivated.
  • tiles: the array of tiles in the game.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HideTiles : MonoBehaviour {

	[SerializeField]
	private string tileTag;

	[SerializeField]
	private Vector3 tileSize;

	[SerializeField]
	private int maxDistance;

	private GameObject[] tiles;

	// Use this for initialization
	void Start () {
		this.tiles = GameObject.FindGameObjectsWithTag (tileTag);
		DeactivateDistantTiles ();
	}

	void DeactivateDistantTiles() {
		Vector3 playerPosition = this.gameObject.transform.position;

		foreach (GameObject tile in tiles) {
			Vector3 tilePosition = tile.gameObject.transform.position + (tileSize / 2f);

			float xDistance = Mathf.Abs(tilePosition.x - playerPosition.x);
			float zDistance = Mathf.Abs(tilePosition.z - playerPosition.z);

			if (xDistance + zDistance > maxDistance) {
				tile.SetActive (false);
			} else {
				tile.SetActive (true);
			}
		}
	}

	void Update () {
		DeactivateDistantTiles ();
	}

}

Then, in the Start method we use the FindGameObjectsWithTag method to retrieve the tiles in our game using the tileTag. Those tiles are saved in the tiles array, so that we can call the DeactivateDistantTiles method.

The DeactivateDistantTiles method, by its turn, will check the distance from the player to each tile in the game. Notice that the tile position is added with half of the tile size. That’s because we want to measure the distance from the player to the center of the tile, and not its bottom left corner. If the sum of the distances in the X and Z indices is greater than the maximum distance, we deactivate the Tile. Otherwise, we activate it. Finally, this method must also be called in the Update method, so that we keep updating the tiles status.

Now, in order to test our Script we need to add a Tile tag and a Player object. In order to add the Tile tag, select an object, click on the Tag menu and select Add Tag. Then, create a new Tag called Tile. Finally, you can assign this Tag to all the tile objects.

Terrain 0 0 object in the Unity Inspector

In order to create the Player object, we are going to import a Unity package. So, in the Assets menu select “Import Package -> Characters”. You can import all the Assets from the package.

Import Unity Package window with Standard Assets selected

This will create a Standard Assets folder inside the Assets folder of your project. Drag and drop the FPSController (Standard Assets/Characters/Prefabs/ FPSController) prefab into your game. This will be the player in our game, so let’s rename it to Player and add the HideTiles Script to it. Remember to properly set the Script attributes. In this tutorial I’m going to set 256 as the maxDistance attribute.

Player object in the Unity Inspector and Hide Tiles script

Now, you can try playing the game to see if the distant tiles are being properly deactivated. You can put the Scene view in the left side of the Unity Editor (alongside the Object Hierarchy) so that you can see its content while moving the player in the game.

Unity world map in a cross shape

And that concludes this tutorial. In the next one, we are going to add more stuff to our world, as well as adding a fog to hide the distant tiles that are being deactivated.

In the meantime, you can further expand your skills by learning about sound design for 3D worlds as well – another must-have feature to create the right atmosphere! You can also expand your Unity skills in general with online courses for both individuals or classroom settings, since one needs a game project to make use of a game world.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>
How to Use Materials in Unity to Customize Game Assets https://gamedevacademy.org/how-to-use-materials-in-unity/ Sun, 18 Dec 2022 01:00:15 +0000 https://gamedevacademy.org/?p=12933 Read more]]>

You can access the full course here: Intro to Game Development with Unity

Unity Materials

What is a Material?

Materials define how an object looks. Is it metal, plastic, wood, rough, soft, translucent? Materials allow you to define the specific characteristics of an object. A car has a metallic material. A tree has a rough and textured material.

Creating a Material

Let’s go down to the Project Browser and create a new folder to store all of our materials. Right click in the Project Browser and select Create > Folder. Call the folder Materials.

Create Folder menu selection in Unity

Materials folder in Unity Assets

Next, we want to double-click the folder to open it up. Inside, let’s create a new material. Right click and select Create > Material. Call the material MyMaterial.

New material created in Unity Assets

You’ll see that if we select the material, something happens in the Inspector. It displays all of the internal workings of the material. Here, we can modify the properties.

New material as seen in Unity Inspector

Let’s look at a few properties.

  • Albedo is the direct color of the material. You can give it a texture or change the color.
  • Metallic is a slider that ranges from 0.0 to 1.0 and defines how metal-like the material looks.
  • Smoothness is a slider that ranges from 0.0 to 1.0 and defines the roughness of the material.

Try experimenting with these values.

Albedo, Metallic, and Smoothness circled for Unity material

Applying the Material

Now let’s apply this material to an object. In the Hierarchy, right click and select 3D Object > Sphere to create a new sphere GameObject. Let’s then go down to the Project Browser and drag the material on top of the sphere in the Scene View.

Material being dragged onto Sphere in Unity

You’ll see that nothing really happens and that’s because the material is blank. Select the material and go over to the Inspector.

  • Set the Albedo Color to red

Unity material with Albedo set to red

Here’s what it looks like with a Smoothness of 1.

Unity material with smoothness set to 1

Here’s what it looks like with a Metallic of 1.

Unity material with metallic set to 1

Next to the Albedo property, click on the small circle. This allows us to select a texture.

Unity Texture selection window for material

A texture is an image that’s wrapped around an object.

Unity material with checkerboard texture added

Materials also have a rendering mode. This defines how an object is rendered along with others around it. Right now, we have a rendering mode of Opaque. This means that the object is solid and not see through. We can change it to Transparent. This means we can change the opacity of the material and see through it.

Unity Rendering Mode options for materials

With Transparent selected, we can modify the Albedo Color. If we modify the A (alpha) value, this will change how see through the material is.

Unity material made transparent

Challenge!

Create a material which you could apply to a car, with the following parameters:

  1. Green
  2. Shiny

Challenge Solution

Here’s how we can complete the challenge:

  • Create a new material called GreenCar
  • Set the Albedo Color to green
  • Set the Metallic to 1.0
  • Set the Smoothness to 1.0

Unity Inspector properties for shiny, smooth, green material

Next, create a new sphere object and drag on the material to apply it.

 

Transcript

Welcome back, everyone. In this lesson, we are going to be looking at materials inside of Unity.

So first of all, what is a material? Well, materials define how an object looks. Is it metal? Is it plastic? Wood, rough, soft, translucent? Materials are the properties that we apply to an object in order for it to look a certain way. So now let’s hop over to Unity and begin looking at how we can actually create a material.

Okay, here we are inside of Unity. Now, the first thing I want to do is go down to my Project Browser here. And what we’re gonna do in our Project Browser is create a new folder to store all of our materials. Because with our materials, we need to store them inside of a folder, because a material is an asset. So to create a new folder, I’m going to right click here in the Project Browser. Go up to Create, and then Folder. Then we can give this folder a name. I’m gonna call this one Materials.

So let’s double click to open it up. And inside of our Materials folder, we want to create a brand new material. And to do that we can right click, and right clicking here in the Project Browser basically brings up this menu, which allows you to interact with it. You can create new objects, you can import assets, you can do a lot of different things here. So we’re gonna go up to Create, and then we are gonna go to where it says Material right here. And like with a folder, we can give this material a name. I’m gonna call this one MyMaterial. And of course, if you were creating specific materials, then you would give them names such as wood, maybe grass, depending on what that material is.

Okay, so we’ve created our material, and straight away you may see that if it is selected, over in the Inspector, we have a lot of information being displayed to us, because the Inspector not only shows us the insides of game objects, it also shows us the inside of whatever asset we have selected. And with material, we can modify its properties over in the Inspector.

So if we look over in the Inspector, you’ll see there are a number of different things. But to see all that changed in action, we should create a Game Object. So I’m gonna go over to our Hierarchy here. I’m gonna right click, and I’m gonna go 3D Object, and let’s create a sphere. Okay, there we go. We got a sphere on screen right now.

Now I’m gonna go down, I’m gonna select the MyMaterial again. And what I’m gonna do is I’m gonna change a value in here. You see where it says Albedo? This is basically the appearance, the color of the object. What color is basically being displayed on this material. You’ll see next to it here we have this color box, a color selector. And what we can do is just left click on the white box like so, and it brings up a color picker where we can basically pick a certain color.

Now, let’s just say we wanna create a red sphere. Well, I’m just gonna drag up to the red like so. And then once we have red selected, you can see it has changed here in the material. We can click X on that window, and that color is applied. But we don’t have it applied to our sphere yet. And in order to do that, we can simply go to our Project Browser, click and drag on the material, and put it on top of the sphere like so, let go, and it is now applied to our sphere. Just like that. And now we have ourselves a red sphere.

So let’s go over to our Inspector right now, let’s select the MyMaterial, and have a look at some of these other properties. And now we can actually see it directly being applied to the sphere. So after Albedo, we have Metallic and Smoothness. Now, these define how light interacts with this sphere. Is it going to be reflective? Is it going to not be reflective? Is it going to be metallic?

So, pretty much the Metallic value, we can click and drag this slider from zero all the way up to one. And as you can see, our sphere starts to look a bit more metallic. So if you’re creating a car, you might want to have one on the Metallic value so it looks like a nice, shiny car. But I’m gonna bring that down to zero.

And let’s look at Smoothness. Now, Smoothness is basically the direct correlation to how reflective this sphere is. Is it going to reflect no light or is it gonna reflect all the light? Right now it’s on 0.5, so if we drag this down to zero, you’ll see that this sphere is now reflecting nothing. But if we drag it up even more to one, you’ll see that it is starting to reflect the surrounding skybox. We can see the horizon line here. We can see the sky here. The underneath the horizon right here, which looks like our skybox around us.

Okay, so if you want a super, super shiny metallic object, you’d probably want Metallic and Smoothness up to one, and there we go. But I’m gonna bring Metallic down to zero, and I’m gonna bring Smoothness down to around 0.5. Just ’cause it looks kind of nice, like so.

Something else you may want to keep in mind is if you want a texture applied to your material, such as like an image, maybe you want some grass texture, maybe you want a brick texture for a wall, you can go over to where it says Albedo. And next to Albedo there is a little square and a circle. If we click on this little circle with left mouse, it will bring up this window right here where we can select a texture.

And this is just gonna be a texture that is applied to the material. So we don’t really have any in our project just yet, but if I click on where it says Default-Checker right here, you’ll see if I click on X, we have this default checker texture applied with a red tint. This tint’s the albedo texture, so I can just select the color again, change this to white, and there we go. Okay, so we looked at getting ourselves a color, making it have a texture, seeing how shiny it can be.

Now let’s look at the rendering mode, which is something you may want to look at if you do want something that is see through. So, right now, our material is set to a rendering mode of opaque, which means that it is a solid object, we cannot see through it. But if we click on this drop down here, you’ll see there are a number of different things. And what we went to look at is Transparent down here.

If we select Transparent, straight away, nothing really happens. But if we click on our albedo color right here in the color picker, you’ll see at the bottom we have an R G B and A values. R for red, G for green, and B for blue. These are different color values which make up all the colors that we see. But what is A? Well, A stands for alpha, and that is the opacity or the transparency. Right now it’s at one for being fully opaque. But if we drag this slider down, you’ll see that we can start to see through the object. So if we put it at around 0.5, you’ll see that our sphere is now slightly translucent, we can actually see through it a bit.

All right, let’s have a bit of a challenge here. I want you to go ahead and create a material which you could apply to a car with the following parameters. It has to be green and it has to be shiny. So I want you to create a brand new material and have these properties, and then apply it to an object. So, I’ll be right back in just a second to see how you done.

Okay, so I hope you had a go at completing that challenge. Now let’s go ahead and look at how we can do just that. So, down here in the Project Browser, inside of our Materials folder, I’m gonna right click. I’m gonna go Create. I’m gonna go Material. I’m gonna call this material GreenCar.

Then what we want to do is go to the Inspector of the GreenCar material. I’m gonna change the albedo color here to be a nice green. You can use the circle here to change the hue. There we go, change it to green. And then I’m gonna drag the metallic all the way up and the smoothness all the way up. Now, let’s create a brand new sphere inside the hierarchy. I’m gonna right click, go 3D Object, Sphere. I’m just gonna move this over here a bit away from the other sphere that we already have. And I’m gonna drag on the GreenCar material like so.

And there we go. That is our material. Now, what I want you to do from here is just go ahead, experiment with various different material types. Maybe even explore some of the other options inside of the material that we didn’t look at. And just see what sort of things you can create, as there really are endless possibilities. So, thank you for watching, and I’ll see you all in the next lesson.

Interested in continuing? Check out the full Intro to Game Development with Unity course, which is part of our Unity Game Development Mini-Degree.

]]>
How to Import Blender Models into Unity – Your One-Stop Guide https://gamedevacademy.org/how-to-import-blender-models-into-unity-your-one-stop-guide/ Sat, 10 Dec 2022 19:11:35 +0000 https://gamedevacademy.org/?p=4399 Read more]]> In an ideal world, exporting models from Blender into Unity for your 3D / virtual reality games should be a seamless, simple process. To be more precise, it shouldn’t require any thought or whatsoever.

At first, it feels like that is the case. You drag and drop a .blend file into Unity and the model shows up! But as people quickly realize when they go through the process, the devil is in the details!

This guide was created to take all pain from the process of importing simple Blender models into Unity, so that at least you know what works for sure and why that is!

As a quick note before you jump in, this tutorial does assume you have some basic familiarity with both Blender and Unity (at least the basics of interacting with the programs).

BUILD YOUR OWN GAMES

Get 250+ coding courses for

$1

AVAILABLE FOR A LIMITED TIME ONLY

1. Coordinate differences

The first thing to keep in mind is that there are two main differences between the coordinate system of Unity and Blender.

  1. Blender uses right handed coordinate system, whereas Unity uses a left handed coordinate system (see illustration below).
  2. In Blender, the Z axis points upwards, whilst in Unity, the Y axis points upwards.

Hands showing the difference between coordinate systems

Image credit: Primalshell, license CC BY-SA 3.0

2. Blender model settings

Say you created a nice-looking low poly tree in Blender, like so:

Creating a tree in blender.

Basic check list before attempting any import:

  • Delete the default Blender camera and lamp. We are not using Blender to create a rendered scene, we just care about the model, so unless you are indeed doing other things with your Blender file, you can remove these elements. Make sure to name your model as well.

Blender scene hierarchy showing our objects and collections.

  • Apply transforms. On the Transforms panel, the values for Rotation should show 0 and for Scale 1 on all the axes. Press Control + A > Rotation & Scale.

Why is this? In Unity you want to be able to apply transforms to your models. If they already come with weird numbers in there this will be confusing.

Setting the model's rotation and scale.

Applying the object's rotation and scale to normalize it.

  • Set the origin to a meaningful position. This might not apply to all cases, but for instance if in Unity you’ll have the floor on Y = 0 (Y as in vertical coordinate), and your Blender model (in this case, a tree) will go on ground level as well, it’ll be much easier if you set the origin in Blender to the base of your model.

To change the origin in Blender, select the Cursor tool and click where you want to place it. To be more precise, Open the View window and set the location of the 3D cursor manually.

Assigning the origin of the model to the middle-bottom.

In order to set the origin of the model to the 3D cursor: select the model, then navigate to Object > Set Origin > Origin to 3D Cursor.

Set origin, origin to 3D cursor.

Why is this? If you set the origin to say the middle of the model, when you import it to Unity and drag them to your terrain / floor, the middle of the model will be on Y = 0, so you might have to drag your model up each time.

  • Keep an eye at the location transform in Blender. When you place your model in Unity you will most likely move it around, so you don’t have to set the location transform in Blender to 0 as it won’t do much. However, if you have a really high number in there, the model will show far away in Unity as well, so keep an eye there and setting it to 0 won’t hurt.

Assigning the model's location, position.

  • Make normals point outwards. Sometimes when importing a model into Unity, it appears as some faces are invisible. This is caused by the normals of those faces pointing inwards. If you are experiencing this issue try the following:

What is a normal? In a mesh, each face has a single vector which is perpendicular to the face. This vector is called a normal and it points to only one side of the face. Normals are used for rendering.

In your model, all normals should always point outwards. To do that, go to Edit Mode, select all faces, go to Mesh > Normals > Recalculate Outside.

Recalculating the model's normals so they all face outwards properly.

What if I need to show both sides of a plane? Like a wall that separates two rooms for instance. In those cases you should use a cube mesh shape for instance, or duplicate the face (you can extrude the face and move it slightly to the other side), you should never have a single face that will be looked at from both sides.

What about backface culling? Unity only supports one-side rendering per face, so enabling/disabling backface culling in Blender won’t make a difference. Backface culling is when you explicitly tell your program that only one side of a face should be rendered.

3. Importing .blend files vs importing .fbx files

You have two main options to import a Blender file into Unity. There is no correct answer here, as different workflows and cases might find one approach better than the other one:

  1. Importing the .blend file directly into Unity
  2. Exporting a .fbx file from Blender, then importing this file into Unity

When you import a .blend file into Unity, what really happens behind the scenes is that Unity will call Blender’s export scripts to generate a .fbx file, and then import this file into Unity.

At first that sounds like both paths should be 100% equivalent. However, that is not the case!

3.1. Importing a blend file into Unity

Simply drag and drop the .blend file into a location inside your Assets folder in your Unity project. You can place the file there by many difference ways:

  • Put it there using the File Explorer
  • Drag and drop it into your Project tab
  • Save your Blender project in there

After that, simply drag and drop the asset into your Scene. The file to grab is the light blue box.

Importing the model into Unity.

If you click on your newly created object and take a look at the transform panel, you will see that the scale is 1, and a rotation of “almost” -90 applied on X.

The X axis will be reversed from what you had in Blender. Whatever value of X was positive in Blender, will be negative in Unity. Usually this doesn’t matter, as the model looks exactly the same. Once the model is in Unity you can move and rotate at glance.

If you want the X coordinate to match, in Unity you have to apply a rotation of 180 degrees on Y. In this case, the Z axis still won’t not match given the different coordinate systems used in each program (the only way for all axes to match would be to “mirror” the model, for which you can easily give it a scale of to -1 in either X or Z in Unity).

3.2. Importing a fbx file into Unity

To export an fbx file, go to File > Export > FBX (.fbx).

To make sure that we’re not exporting anything we don’t need (camera, lights, etc), only select Mesh in the Object Types. If you have a rig for a character model, make sure to also select Armature (select multiple by holding down Shift).

Since Unity and Blender have different coordinate systems (Z and Y are flipped), we need to enable Apply Transform to make the transform coordinates work for Unity.

Now we can click the Export button to export the model to our desired location.

Blender fbx export settings for Unity.

Note: if you are exporting the whole scene, clicking that button won’t make a difference, but if you are exporting only selected objects, not checking this option will cause them to be imported into Unity with a scale of 0.01, instead of 1.

To import the fbx file into Unity, simply place in the Assets folder and drag into your scene just like we’ve described for blend files.

The model will show just fine, but the Inspector panel will show a File Scale of 0.9999999 which is almost 1. We can deal with that.

If you drag the mesh into the scene and check the Inspector panel, you will notice that the scale is set to 1, that means we are on the right track.

Regarding the horizontal plane coordinates, if you want the X direction to match that of Blender, you have to apply a rotation of 180 degrees in Y in Unity, like like we did for blend files!

4. blend vs fbx? Which one wins?

There is simply no correct answer to that question, as both options have their pros and cons and that will depend also on your own workflow. The important thing is that by following this tutorial you can now import your Blender assets correctly no matter your choice.

Which approach should I take? Perhaps these guidelines can be of help:

  • If you have multiple models in a single Blender file, you can easily export one by one as fbx files as described in the tutorial.
  • If you have a single Blender file per model, it’s easy to just move these files into Unity, or even create them inside the Asssets folder to begin with!
  • Important. After importing a blend file into Unity, if you modify and save that file in Blender, the objects in Unity that use this asset will be updated too. This can help you save time, as you don’t have to export again. However, it can also mean you have to be careful if you are making changes in Blender, as you can easily mess up your game objects by some unintentional transforms and location changes.
  • On that sense, exporting fbx files makes this process manual, so even if you save changes in your Blender file, these won’t propagate into Unity unless you choose to.
  • Importing blend files requires Blender to be installed. Since Blender is a free program this is not a big deal, but it’s good to know.

Ending Thoughts

Thanks for reading and I hope you found this tutorial helpful!

Some useful resources and discussions on this topic:

You might also want to check out our developer job prospects article or our coding portfolio article to help make the most of your projects!

Lastly, if you’re looking to expand your skills with Unity or Blender, we recommend checking out the Unity Game Development Mini-Degree and Game Artwork Academy for fantastic online courses on those topics. Educators can also try out Zenva Schools which offers online courses for K12 classrooms in those topics as well (and comes with nifty features like classroom management tools, pre-made course plans, and reporting.

BUILD GAMES

FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.

]]>