Unity Gaming: Particles! (part 2)

So in the last post I talked about the Particle System basics. In this post I’ll be delving deeper in using particles systems in your game and talk about Particle Shaders and Textures.

Textures, Texture Sheets, and Shaders

Usually when we talk about Textures and Shaders we are talking about applying them to a material for a gameobject in your scene. For those of you who are new to working on the front-end side of development, a Texture determines what an object will look like (color, designs, etc.) while a Shader determines what attributes the texture will have (shininess, transparency, reflectivity, etc.).

To be more specific, a Shader is defined as:

The method to render an object. This includes code and mathematical calculations that may include the angles of light sources, the viewing angle, and any other relevant calculations. Shaders can also specify different methods depending on the graphics hardware of the end user. The parameters that can be customized in the material inspector, such as texture maps, colors and numeric values.

Most developers only interact with Unity’s standard shader. It’s very powerful and can achieve many of the effects that developers want, like glass, metallic, matte, or holographic appearances for their objects. However, in addition to the Standard Shader, there are a number of other categories of built-in shaders for specialized purposes:

  • FX: Lighting and glass effects
  • GUI and UI: For user interface graphics
  • Mobile: Simplified high-performance shader for mobile devices
  • Nature: For trees and terrain
  • Particles: Particle system effects
  • Skybox: For rendering background environments behind all geometry
  • Sprites: For use with the 2D sprite system
  • Toon: Cartoon-style rendering
  • Unlit: For rendering that entirely bypasses all light & shadowing
  • Legacy: The large collection of older shaders which were superseded by the Standard Shader

Using different Textures with Shaders

So far we have only used the default particle texture with the default particle shader

1-1-DefaultParticleTex

Let’s import more assets to work with.

Assets>Import Packages > Particles

This package comes with a variety of different textures, materials, and prefabs we can use and edit for our purposes. It also imports some default particle shaders for us to use.

Depending on the effect you want to accomplish Textures can be a single image or a sheet of images that is used like an animation sheet; and depending on how you want the texture to render in your scene you need to use a corresponding shader.

Now, I’m not going to explain the intricacies of shaders and how they work, it’s way to in depth for a short blog post. But I’ll touch on some of the basics of the two main shaders and they types of textures they work with.

Additive Shader

Look under the prefabs folder of Under Assets>Standard Assets> Prefabs

Select the Afterburner prefab and drag it into your scene. This prefab is a great example of a Particle System using Additive Shaders; what’s even better is that it’s using the same Texture as the Default-Particle System.

3-1-AdditiveTexture

Additive blending is the type of blending we do when we add different colors together and add the result. This is the way that our vision works together with light and this is how we can perceive millions of different colors on our monitors — they are really just blending three different primary colors together. You can read more about here: http://www.learnopengles.com/tag/additive-blending/

This type of blending has many uses in 3D rendering, such as in particle effects which appear to give off light or overlays such as the corona around a light, or a glow effect around a light saber. If you go through the inspector of the Afterburner prefab you can see the specific settings for each of the particle system modules.

Alpha Blended Shader

Now to show you about Alpha Blended particles go into the same folder as before and select DustStorm and drag it into your scene. You can delete the afterburner prefab. The DustStorm Particle System uses a different texture than the default and afterburner systems.

2-1-AlphaBlendedTex

2-2-AlphaBlenedTex

This cloud has a black (0) alpha channel, making the black parts of the image not effect any of the pixels in the layers under it.

Think of a layer of colored glass or colored semitransparent plastic on top of something of another color. That’s the effect accomplished with Alpha blending. Alpha blending is a blending technique that allows for the combination of two colors allowing for transparency effects. The alpha blending equation is as follows:

final color = src color * src alpha + dest color * (1-src alpha)

What this does is linearly interpolate between the two colors according to the alpha value. If a src pixel has an alpha of 0.8 it contributes 80% of the final color while the destination pixel only contribute 20% of the final color of the new pixel color. This obviously means the lower the source pixel alpha the larger the contribution of the destination pixel. To read more about it check out this link: https://takinginitiative.wordpress.com/2010/04/09/directx-10-tutorial-6-transparency-and-alpha-blending/

Let’s see the difference between the two shaders. Go into the inspector and change the Shader of the DustStorm to Particles/Additive instead of Particles/AlphaBlended.

3-2-AdditiveDust

Now you can see that the Dust now has a glow about it as it layers, instead of the transparent quality it had earlier.

Yay! Shaders and Textures complete! In the next post I’ll show you how to make your particles interact with objects in your scene.

Happy Coding!

-TheNappingKat

Unity Gaming: Polish – Particles!

So far in this series I’ve showed you how to make an infinite runner; talking about spawners, destoryers, character controls, handling collisions, and music. Now I’ll show you another way to polish your game; Particle Effects. Particle Effects are an easy way to add that extra wow factor to your game without too much effort.

There are several things you can do with the Particle System Unity provides. You can make streams of water, fire works, explosions, lightning bolts, OR ominous yellow radioactive acid fog (the 100 reference, you should watch it, it’s on Netflix) I find the best way to learn about how to create all the different effects is to play with them yourself. So, by the end of this post you will have a barrel leaking yellow radioactive material shown below.

Unity_Radioactive_Barrel

I’ll also talk about WHY the particles look like they do and HOW we can effect them through the editor.

Understanding Particle Systems

Particle Effects are generated by a Particle System. Any gameobject within Unity can have a Particle System component.

A Particle System is, at it’s core, a Spawner, that spawns texture sheets at a specific location with certain properties defining lifetime and behavior. So we’ve done something like this before. However this time Unity provides a nice Inspector Menu to tweak the behavior and lifetime of the object being spawned. Also, Unity’s Particle System is dynamic. This allows the emission and lifetime settings affect the overall behavior of the system but the individual particles can also change over time.

Unity also provides lots of documentation on each module of the Particle System. Modules are the different sections in the Particle System Component in Unity. Now, I won’t go over all the modules of a Particle System and their properties but I’ll definitely highlight the popular ones as we make the prefab.

  1. Main, Emission
  2. Shape
  3. Color Over Time
  4. Size over lifetime
  5. Collision
  6. Sub Emitters
  7. Renderer

Step 1: Set Up and Default Emitter

So in a new scene I’ve added a Cylinder and a plane to the scene along with an empty GameObject and called it Particles. I then rotated the Particles object -90 in the X axis of the transform and added a particle system component to it.

1-0-Particles

Once you’ve added the particle system to your scene you will see little white glowing balls of light being generated and then disappearing. This is because of Unity’s default settings for it’s Particle system.

1-1-ParticleGenerated

1-2-ParticlesInspector

The little balls of light are created because that’s the current texture assigned to the system. The texture could be changed to whatever you want, like pictures of your face or smoke. I’ll talk more about textures and shaders later on. The point at which the particles are generated is called the Emitter.

Step 2: Main

The Main module of the Particle System controls properties of the system overall.

2-0-Main

Duration is the length of time the system will run. Most of the properties in this module control the initial behavior of the particles from the emitter. I’ve made the duration 5.00 which translates to 5 seconds.

Looping – This boolean value triggers whether or not the system will loop. If selected it will then repeat in 5 second (the duration) intervals.

**SIDE NOTE: Start Delay, Lifetime, Speed, and Size can be customized by selecting the down arrow on the side, and selecting one of the following options: Constant, Curve, Random between Two Curves, and Random Between Two Constants (The 4 Options). These Options allow the System to behave dynamically, emitting particles at different sizes, at different times, and with different speeds.

Start Delay: 0 – How many seconds after the system start would you like the first particles to be emitted.
Start Lifetime: 5 – Lifetime for the the individual particles emitted
Start Speed: 2 – How fast the particle travels outward from the emitter
Start Size: 4, 7 (Random between two constants)- How large the particles will be

Start Color – Yellow and Light green. I also selected Random Between Two Colors. You can choose whatever colors you want.

Gravity Modifier – 0.1 – Scales the gravity value set in the physics manager. A value of zero will switch gravity off. With the Gravity Modifier you do not need to use a lot of force. Play around and see what little gravity you need to force your particles straight down after emission… Hint, it won’t be a lot.

Main should eventually look like this now.

3-1-Main

Step 3: Emission

Rate – 3, 5 – Random Between Two Constants. Unity explains that the rate of emission can be constant or can vary over the lifetime of the system according to a curve. If Distance mode is selected then a certain number of particles are released per unit of distance moved by the parent object. This is very useful for simulating particles that are actually created by the motion of the object (eg, dust from a car’s wheels on a dirt track). However, Distance mode is only available when Simulation Space is set to World in the Particle System section.

3-1-Emission

Step 4: Shape

The Emitter can multiple shapes

    • Sphere
    • Hemisphere
    • Cone
    • Box
    • Mesh
    • Mesh Renderer
    • Skinned Mesh Renderer
    • Circle
    • Edge

3-1-Shape

I’ve selected Cone since I want the particles to fountain out of the Barrel.
Angle – 30
Radius – 1 – Same as the radius of the barrel.
Emit from: Base

Step 5: Color Over Lifetime

Color Over Lifetime can be set with one Gradient or Random Between Two Gradients. I’ve chosen Gradient, and set the color to White; and then changing the alphas at the beginning and end to 0 to fade in and then fade out creating a radiating glow from the particles. You can change the colors and alpha for the gradient by clicking on the gradient field.

3-3-ColorOverLifetime

Step 6: Size Over Lifetime

To Edit the curve of Size over Lifetime you need to open the editor for Particle Editing. At the top of the Particle System Component in the Inspector Click – Open Editor…

3-4-SizeOverTime

Once the Editor has popup you will see the settings for your particle system as well as a graph. Unity has some default curves for you to choose from at the bottom of the grid. My curve starts at .5 and arcs up to 1.

3-4-SizeOverTimeGrid

You can also use the editor to tweak the modules that we were editing before.

Step 7: Collision

The collision module determines whether or not the particles will collide with 3D, 2D, or plane objects. I have it selected because on collision I want a secondary effect to happen, which we can edit with the sub-emitter module.

3-5-Collision

I’ve chosen my particles to collide with objects in the 3D World space, with no dampening force or bounce on the particles so they stay on the ground and keep their velocity. I also want dynamic collisions but not with itself. I could also check the box for Send Collision Message, but I’ll save that for later.

Step 8: Sub Emitters

Sub Emitters are secondary particle systems that are parented to the initial particle system created. They are great for creating secondary effects on actions. Unity likes using the example of a bullet that might be accompanied by a puff of powder smoke as it leaves the gun barrel and a fireball that might explode on impact. Those sub-emitters would be added to the Birth and Collision section respectively. Since sub-emitters are simply particles systems they can have sub emitters of their own, allowing you to create complex effects like fireworks. However BE CAREFUL this can lead to a numerous amount of particles in your scene and slow performance greatly.

When you initially look at the Sub Emitter Module it contains three sections, Birth, Collision, Death with two slots each, saying, “None”.

4-0-SubEmitter

As I mentioned before I want my particles to have a secondary effect on their collision. So to add a sub-emitter to my scene I simply have to select the plus sign next to the first Collision slot. The default sub-emitter of white lights will be created. To prevent the onslaught of pretty white lights filling up my scene, get ready to click stop on the particle system in the scene tab. This will save you a lot of grief as your machine might slow down a bit.

4-1-Stop

Now to save time I’ll screen shot the modules of the sub-emitter for you to copy.

4-2-SubEmitter

PART 2.

4-3-SubEmitter

I’ve only changed a few things. The shape of the sub-emitter is a hemisphere, and the color over lifetime is a bit more colorful. Also notice that the Collision module is on as well but I do not have any more sub-emitters attached.

Step 9: Renderer

Now this module is related to the texture sheet that is attached to the particle system. Overall the Renderer determines how a particle’s image or mesh is transformed, shaded and overdrawn by other particles. Since we are using the default texture sheet I’ve kept the Renderer settings on their default as well.

5-1-Renderer

Tweaking the System

Now there are several other examples that you can checkout from Unity in the editor. Simply go to Assets and Import the Particles Package

6-1-ImportParticleSystem

And there you have it! Your first Particle System! Now take what you’ve learned and play around with more of the settings. I did skip over some things, like Send Collision Messages, and the Texture Sheet Animation module. I will cover those in my next post where we have these systems interact with our player.

Happy Coding!

-TheNappingKat

Unity Gaming: Music and Sound (part 2)

So in Part 1 of Music and Sound I talked about creating your own game music. Now I’ll show you how to integrate the music into Unity.

Unity updated many things about their engine in the latest release. One of the biggest overhauls they did was toward sound creation and manipulation within the engine. This post will go over the basics of using the sound engine but if you want to take it to the next level here is a link to Unity’s advanced tutorial on making sound groups and mixers: http://blogs.unity3d.com/2014/07/24/mixing-sweet-beats-in-unity-5-0/.

Background Music

Sound and Music is sometimes the most underrated thing game developers take into consideration when making their games. But what they don’t realize is that extra addition can take a game from great, to epic. Imagine Super Mario or any of the Final Fantasy Games without their phenomenal score. The ability to completely immerse the player would be lost. Movies use music to manipulate the mood of the audience in order to provoke certain emotions; fear, sadness, anxiety. Games can use music to do the same. For example, speeding up music can create a feeling of intensity and urgency.

Implementing Sounds in Unity

Before we begin here are some Unity terms that you should know:

  • Audio Listener – controls audio output to the headphones.
  • Audio Source – where the sound comes from
  • Audio Clip – sound file
  • Audio Mixer – Controls Audio Groups
  • Audio Group – Channel for certain clips and effects

To create sound in Unity you need at least three things. I’ll leave Audio Mixer and Audio Groups out for now.

  1. Audio Clip
  2. Audio Source
  3. Audio Listener

Step 1: Create Audio Game Objects

In your hierarchy create a empty gameobject and call it SoundManager. I like to organize my sounds by putting them in an empty SoundManager Object.

Step 2: Add Audio Source to the SoundManager

CreateAudioSource

Step 3: Add Audio Clip to source

Create an Audio folder in your “Assets” folder. This folder will hold all your sound clips.

AudioFolder

Take the sound file you created from the previous post, and with your Explorer (or Finder for Macs) move it to this Audio folder.

Then add this clip to the Audio Clip area of the Audio Source you added to SoundManager.

SelectAudioClip

Make sure that the Loop and Play on Awake boxes are selected as well. This will ensure that your music will play throughout your game and will play at the creation of the SoundManger object.

LoopAudioClip

Step 4: Add SoundManager Script

In your scripts folder create a new script and call it SoundManager. This script can control certain effects that can be applied to your clips, like pitch controls; however I’m only use it to will ensure the game music is playing.

    public AudioSource musicSource;
    public static SoundManager instanceSM = null; 


	// Use this for initialization
	void Awake () {
	}



	// Update is called once per frame
	void Update () {
        if (!(GetComponent<AudioSource>().isPlaying))
        {
            GetComponent<AudioSource>().Play();
        }
        else
        {
            //Debug.log("Something is wrong with Music.");
        }
	}

And there you have it. If you press play your music should start playing. I’ll continue talking about adding sound effects to specific game objects in my next post, as well as getting into Audio Mixers.

Happy Coding

-TheNappingKat

Unity Gaming: Creating Game Music and Sound Loops

So for game developers worrying about the music is one of the last things on our minds. It shouldn’t be. Music gives games the extra layer of professionalism that immerses players into the gaming experience.

Now there are a bunch of free loops online. And if you want something professional you can always pay someone to write a small loop for you too. However, for those of us developers that want our games to have a unique sound, (and have an hour or two to kill) we can create our own music loops.

One of my favorite tools to do this is Audio Sauna. It’s a really good off/online music editor and gives games a very 80s feel, with the synths and samples it uses.

IT’S SOOOO EASY TO USE! Don’t just have the same generic garage band samples that everyone has. Trust me. There. Is. A. Better. Way.

Now, I am no composer, producer, music maker, so this is just my 2 cents on how to create song for your game.

Intro to Audio Sauna

To get started you can go to the audio sauna site:

AudioSauna1

They have a great online studio for quick sound loop generation. When you open the studio you should see a screen like this:

AudioSauna2

Do you see it? Great! Okay so what are we looking at. Well the studio works like most big audio applications with a menu bar at the top some editing hotkeys below that. Your main editing area in the middle, with the source input area. And the mixer, is located at the bottom.

Creating Music

Step 1: Choosing Sound Inputs

So the art of making loops, beats, music in the studio is by creating rhythms and layering different inputs together. The studio already has up one of the default inputs: the Analog Synth. Down in the Mixer you can see that the “Analog Synth” is colored red instead of blue. This indicates that it is selected and that is the current track you are editing.

Let’s take a closer look at the Analog Synth. input. So it seems pretty daunting at first but after playing around with it for a while it gets easier to understand. On the left Audio Sauna has created some presets for you to use.

AnalogSynthIntro1

Now the AWESOME thing about this tool is that you can use your qwerty keyboard as a regular musical keyboard! “But wait?!” You exclaim, “There are way more keys on a musical keyboard than a computer one.”  Yes. The tool gets around this caveat by having an octave button that will bounce your input up and down the keyboard’s(musical) keys.

AnalogSynthIntro2

 

See my mouse isn’t anywhere on the screen but when I hit the keyboard key the corresponding musical keyboard key depresses.

 

AnalogSynthIntro3

 

**I’m just noticing how confusing referencing your key from your keyboard and key from your musical keyboard is getting, so I’m going to call the musical keyboard key’s “mkeys”.

Step 2: Writing Notes

You might have also noticed that the side mkeyboard is also depressed.

AnalogSynthIntro4

The mkeyboard in the main editing area, is the full standard mkeyboard. And shows you where your note will be placed in the sheet time line. You see there are two ways of adding notes to your loop’s “sheet music”. One, using your keyboard. Two, using the pencil edit tool right on the timeline.

AudioSauna6

The Pencil tool allows you to click inside of the timeline sheet and create notes that will be triggered on play. If you exit out of the Analog Synth. input editor, you will see the plain editing sheet. However the notes you create will all be on the short 1/16 beat. To change how long the note lasts just change the 1/16 to a larger fraction, by clicking on it.

 

AudioSauna3

At the top of the sheet you can see a green bar. The green bar on the top signifies the length of the loop.

Step 3: Recording Music

Now to actually save any noise you have been creating you need to record your key input.

Let’s get the Input tool back. By double clicking the red Analog Sync. will bringing it back into view. Click on the keyboard to start using the keyboard to manipulate the mkeys. Now hit the record button on the bottom.

AudioSauna7

The green bar is now highlighted over with a red one, to signify that it is recording your key strokes now. Each time you press a key a red mark should appear one 1/16 at a time.

 

AudioSauna8

 

Great! now keep playing around with the beat until you fill up the loop.

Step 4: Layering beats

So I mentioned that using the tool was meant for layering sounds on top of one another. So lets make those other beats. Click the top right horizontal bars.

AudioSauna10

A new screen should appear. Currently the Analog Synth is selected and is the only track that has notes in it.

AudioSauna11

Now double click on the FM-Synth. The tool will then change back to the editor view, but for the FM-Synth.

AudioSauna12

As you can see below the FM-Synth is now red in the mixer. However, the Analog Synth input editor is still out.

AudioSauna13

To get the FM-Synth input tool out double click on the red FM synth name in the mixer.

AudioSauna14

A new input should appear now, like the one above. This time the presets are on the right hand side. Select one of them and beginning hitting the keys, to hear what kind of sound will be made.

This editor works the same as the one before. So either with the pencil, or in record mode with the keyboard, you can create your timeline sheet music. There is also a Sampler input that you can use. You will have to repeat the process.

Step 5: Saving the Loop

So after you have composed your amazing awesome mix. Lets get it into unity. From the File Menu there are two options you should be familiar with. The Save to My Computer option and the Export Loop as Audio File.

AudioSauna15

You should use the Save to My Computer option when you haven’t quite finished your mix and would like to work on it later. The Tool saves what you’ve done as a session that you can reopen with the tool again. The Export Loop as Audio File is the one we need when we are done with our loop and want to put it into Unity.

 

The next blog post in the series will be adding your saved Loop into Unity!

Happy Mixing!

-TheNappingKat

 

 

Unity Gaming: Unity Ads (part 2)

Implementing Unity Ads

In my last post Unity Ads (part 1) I talked about the importance of Ads, why you need them, and how you should implement them.

Step 1: Sign-Up

Make sure you have a Unity Account before you get started. You will also need a Unity Services account as well. To get one go to https://unity3d.com/services/ads to sign-up and try the free beta.

1-1UnityAdsSignUp

Click “Earn Money with Your Games”.

1SignUpDecision

If you have never created an ad service before your dashboard will prompt you to create a new Ad Project. Do NOT create a new project.  If you create a new project you will have to link the ID that is generated from your editor to this project. Instead, we will create the Ad portion of your project in Unity’s Project Editor.

2-3SignUpProjectOnline

Step 2: Enable Unity Services

Now that you have an account you need to open your game in unity. In the upper right hand corner of the Editor you should see the unity services tab (if you don’t see the tab, hit the cloud icon in the upper right).

ServicesCloud

Before you can enable start using Ads you need to create a Unity Project ID so you can collect your data and view it with Unity’s Analytic Dashboard.

Select “Create” to have Unity create a Unity Project ID.

2EnableUnityServices

Step 3: Enable Unity Ads

After you’ve turned on services and connected generated your Unity Project ID. You should see the available services that Unity provides within the Editor. Currently Analytics and Ads are the only ones available, however multiplayer options and Cloud Build are in the pipeline for future integration and use with the editor.

Turn on Ads by clicking the “Off” toggle to “On” for Ads.

2EnableAds

 

2-1EnableAds

To link this project with our online portal simply click “Go to Dashboard”.

2-1-2AdsCreateProject

The portal for your project should now open in your browser.

3-1Dashboard 3-2Dashboard

 

Step 4: Ads Integration

Now that your project is linked to Unity Ad Services, let’s get some ads in your code. There are two types of Unity Ads:

  1. Simple
  2. Rewarded

To explain these two types, I’ll start with Rewarded. Rewarded Ads keep track of whether or not the player has skipped your ad, or has completed watching the ad. This allows the developer to then reward the player after the completion of the advertisement.

Simple Ads are ads that simply run in your application without any other interaction with your application.

Unity provides some sample code for you to run in your project, which makes it really easy to plug and play with the feature.

2-2EnableCodeSamples

 

In order to test out your ads, make sure that the “Enable Test Mode” button is selected

3-3EnableTestMode

 

Also ensure that you are building to the iOS or the Android Platform.

3-4BuildSettings

When you run the code the ads should look like this:

4-1-1AdShowing

 

And there you have it. Integrated ads in your game!

 

Happy Hacking!

-TheNappingKat

Unity Gaming: Unity Ads (part 1)

Why you want ads

We live in a Free to Play World where most users have grown accustomed to mobile games being free. There are a select few who are willing to pay that up front fee, but your game will already need be popular, have player support, or a good amount of attention to sell it. And of course, console games are an entirely different story.

So how do you get revenue from users who don’t want to spend any money? Ads. Advertisements allow you to have a steady revenue stream as your users play your game.

Now I know what you’re thinking: Ads are horrible, they distract from game play, they take up screen real estate, and they take away from the experience…And yes, they can – if the developer doesn’t design the game to incorporate them in an immersive, consumable way.

In this post, I’ll go over some of the main points of integrating ads into your game and how to do it in Unity’s new services. If you want to read more about it, Unity has a few articles and blog posts about best practices and tips from other indies that successfully incorporate ads in their games:

Implementing Ads Well

Don’t disrupt game play

Have you ever played a game with an annoying banner across the top for a random ad? The answer is most likely yes. one way to avoid advertisements from disrupting game play is to make the decision at the beginning of the design process that you are going to make a freemium game. Knowing that you plan on including ads during the design phase allows you to then tailor your game to strategically use ads instead of slapping them on at the last minute.

Make ads part of the experience of your game. Currently, Unity ads will play full screen and are video based. You can have simple ads or you can have advanced ads that can tell developers if users actually watched the ad or not.

Ad Incentives

To incorporate Ads into the experience of your game you can use ads with an incentive system. For example:

A user is playing your infinite runner and they die. Instead of simply showing their score and a play again button, they see a screen that shows them their score and a choice. 1) Restart and try again, or 2)Watch an ad and start from where they died.

That way, game play has not been disrupted and the ad is showing at a natural pause in the game. Also, by rewarding the player, the user doesn’t associate dying with watching ads, giving them a bad experience with your game when they die.

Don’t break the game

Be wary of adding too much power to incentives.

The incentives and rewards that players receive for watching your ad should not give them an unfair advantage for the game. If your game involves some sort of currency, the reward shouldn’t be great enough to disrupt play. Balance the frequency of showing ads. Show them too often and you’ll irritate players, which might cause them to stop playing your game all together.

How to Implement

Unity 5.2 and higher has Ads support integrated into the editor. It’s a great tool for testing your ad experience. In my next post, I’ll show you how to integrate ads the way I did with Unity Analytics here: Unity Gaming: Anayltics

Happy Hacking

-TheNappingKat

Unity Gaming: Analytics (part 2)

Implementing Analytics in Unity

So in Part 1 of Unity Gaming: Analytics, I talked about the importance of analytics, what it is, why you would need them, and how to understand the data. This part will go over how to integrate them into your game and connect to the Unity Analytics Dashboard. Remember these new analytics are still in Beta and can only work with Unity 5.2 or above. Let’s get started.

Step 1: Sign-Up

Make sure you have a Unity Account before you get started. You will also need a Unity Services account as well. To get one go to https://unity3d.com/services/analytics to sign-up and try the free beta.

1Signup

Step 2: Enable Unity Services

Now that you have an account you need to open your game in unity. In the upper right hand corner of the Editor you should see the unity services tab (if you don’t see the tab, hit the cloud icon in the upper right).

ServicesCloud

Before you can enable start using analytics you need to create a Unity Project ID so you can collect your data and view it with Unity’s Analytic Dashboard.

Select “Create” to have Unity create a Unity Project ID (if you already created a project ID in the Analytics Dashboard tool, you can use that ID to connect to your game with the “I already have a Unity Project ID link below the Create button).

2EnableUnityServices

Step 3: Enable Analytics

After you’ve turned on services and connected generated your Unity Project ID. You should see the available services that Unity provides within the Editor. Currently Analytics and Ads are the only ones available, however multiplayer options and Cloud Build are in the pipeline for future integration and use with the editor.

Turn on Analytics by clicking the “Off” toggle to “On” for analytics.

2.1PickServices

 

The Services tab will then open to the Analytics portion. Click the “Enable analytics

2.1EnableAnnayltics

Step 4: Analtyics Integration and Validation

To view and test your analytics you now need to go to the Analytics Dashboard found online at https://analytics.cloud.unity3d.com. The easiest way to get there is to click on “Go to Dashboard” (make sure you’re connected to wifi).

2.1FinishedEnablingAnayltics

The link will open your default browser and navigate you to the integration tab on your Unity Dashboard.

3Dashboard

To find out if your Analytics Services are correctly integrated, navigate through the documentation, by clicking the Next button. You’ll see a “Play to Validate” page.

Go back to your application and Play it in the editor. The empty box on the Dashboard should now be displaying data about your game.

3.2AnalyticsValidate

 

Trouble Shooting

If there is no data being displayed, stop your game and give the system time to refresh the dashboard. If it still isn’t working make sure that the Project ID in the Dashboard and the Project ID in the editor are the same.

Step 5: Write Custom Events

Now all that’s left to do is figure out what data is important to learn how users are interacting with your game. The next post will explain how to write code to collect custom information specific to your game/application.

 

Happy Coding!

-TheNappingKat

Unity Gaming: Analytics (part 1)

The Importance of Analytics

Analytics are one of the cheapest ways you can increase profit in your game.

When should you Implement?

You’ve created a good playable game, but haven’t released it yet. That’s when you should add analytics.

Also when you ask yourself: Which type of player spends the most money? Is it Americans, older players, ones that struggle to complete levels? When do my players stop playing my game? How long do they play? Why aren’t they spending money on my game?

Why do you need them?

In order for you to take your game to the next level you need to know about your game. More specifically, how your users play your game. It’s nearly impossible to make any good decisions about how to continue development if you don’t have any information to go off of.

Anayltics implemented well, will give you all information you need to learn about who’s staying in your game, who’s stuck and who’s spending money and why. That last one is one of the most important. Game developers can then use those insights to make data-driven decisions to make players love your games even more.

And when users love your game, they are more willing to spend money by buying expansions, in app purchases or play more which means…watch more ads, getting you more money.

What are Analytics

Analytics are event triggers that you’ve implemented at certain points/milestones/areas in your game. They can tell you almost anything about your users. For example, these triggers can tell you: where a player goes in your game; how often they go there; whether or not they collect particular items and special achievements; or which level they die on.

Unity is great because it provides an easy to use and easy to understand Dashboard to visualize your games data.

Unity Dashboard – Metric Monitor

UnityAnalyticDashboard

The picture above shows the main Metric Data that Unity provides for your game. I’ll explain the most common terminology used in the dashboard but the whole glossary of terms can be found here: Unity Glossary of Metrics.

Sessions – how many times your users play your game per week
DAU – Daily Active Users
MAU – Monthly Active Users
Retention – The percentage of average sessions per week

You can also modify what data you collect and display it on a chart in the Data Explorer Tab.

Data Explorer

By default Unity provides metrics on Player Data, Session Data, Retention Data, and Revenue. In chart Below I’ve customized my view to look at: Player Data – MAU; Session Data -Total Daily Play Time; Retention Data – Classified by geo location in the U.S., and a Custom Event that I created in my Game – Bubble Collected. Having this much data in one chart doesn’t really tell me too much though. I’ll talk about how to read data later in the post.

DataExplorer

 

Funnels

Funnels help you identify where drop offs happen in your game aka, when users stop completing a series of events. They are based of custom events that you create in your game. Funnels data is slightly different than regular metric data, in that it needs to be linear. What does that mean? Well when making your custom events the player needs to complete custom event 1, before completing event 2, in order for the data to show up on the funnel. The best example of this is level completion. In the picture below you can see that only 2.4% of users finish the game, and that 100% of users complete level 1 but then drops to 70% at level 2, but then drops drastically to 38% at level 3.
Funnels

Segments

Segment data is used to qualify/organize users based on certain metrics. For example grouping users by location; how much money they spend in your game; how long their session time is, or by age groups. Based on these certain criteria, you can analyze what types of users are completing your game or which ones are spending money.

How do I read this data

Well understanding what you are collecting is very important. Looking at my mock data I can tell that users initially spend money, but my retention for the game is non existent, so users are no longer spending money in the game since they aren’t playing it.

I can then look at my funnel data and see that 100% of users are completing my 100% of the levels. Meaning 1)The levels are too easy, and I should make them harder. 2) I should make more levels so the users stay in the game longer and end up playing multiple times. 3)I need to create new incentives to bring players back into the game.

Alright now how do you implement the analytics in your game? Well that will be in my next post (Unity Gaming: Analytics (part 2))

Happy Coding!

-TheNappingKat

Unity Gaming: Infinite Running with Oculus and Kinect

Infinite Runner – Unity 5 Using Your Body as the Controller

Hey Everyone! NEW ANNOUNCEMENT!

As you know (or are just know learning) the Unity Gaming series on this blog is stepping through how to create a 3D Infinite Runner with Oculus Integration and Kinect Controls! Here’s a video explaining about it below.

Well, there is good news. UNITY 5.2 was released! And as such I’ve decided that this series would be perfect for exporing 5.2’s new features. Thus, the series has been re-vamped for Unity 5! (Well 5.2)

This post will highlight the major changes so you can integrate Kinect and Oculus into your Project!

So let’s get coding!

Unity Changes

This section will walk through all the changes that affect the Infinite runner I’m showing you how to create. This way when you follow along with Unity Gaming Series the code will work in unity 5.2.

Visual Studio

So if you download the new Unity 5.2 you’ll now notice that Visual Studio is now included! This is perfect for development debugging and building for Windows 10.

Oculus Integration AND Windows 10

The awesome thing about Unity 5.2 is optimization for Windows 10, Oculus Rift and other VR/AR devices!

Unity5Oculus

The Code

Create Your Own

The Unity Gaming series was meant to walk you through creating an infinite runner from scratch; teaching good coding practices along the way. You can go back to the beginning with the first post: Unity Gaming: Good Practices Unity

Completed Infinite Runner Game

If you’re only curious in the Kinect and Oculus portion you can start from a completed infinite runner game. The code for the game is on my github here: Base Unity 5 Infinite Runner Game

Here are the step by step guides to integrate:

Completed Game with Oculus and Kinect

If none of those appeal to you and you want to download the whole thing. The link to the completed repo is here: Gravity Infinite Runner

Happy Coding!

-TheNappingKat

Unity Gaming: Oculus Integration – Unity 5

Hey Everyone!

With Unity 5.2 out and all the cool new features with Virtual and Augmented Reality. I thought I’d do a quick tutorial about how to integrate Oculus into your Unity 5.2 or higher project. I’m walking through set up for a windows machine.

Step 1: Download

Go to Unity’s Home page and download Unity 5.2. Then go to the Oculus websites downloads section. Download the SDK, Runtime, and Utilities for Unity.

OculusDownloads

Step 2: Unity Plugins

Import the Oculus Plugin for Unity. In your Unity Project go to the Menu and select Assets>Import Package>Custom Package

In the File Explorer Select the Plugin you downloaded from the Oculus website.

UnityPlugin

Step 3: Oculus Prefab

Drag the Prefab into your scene, or the camera rig onto your character.
Prefab

Step 4: Enable VR development in Unity

The newest and most important step – ENABLE VR FOR THE EDITOR! Do this by going to Player Settings and selecting the box for Virtual Reality Development

PlayerSettings
VRSupported

Now run the Game. It should exactly the same. But if you have an Rift set up the it will mirror the Unity Editor Game View.

And there you have it. Complete integration =)

Happy Coding!

-TheNappingKat