12 Weeks with Unity, Part 7 - Colliders in Detail, Unity Audio and the Lure of the Asset Store

May 01, 2018 at 11:18 am by -gToon

This is the seventh of a series of articles that cover my journey learning and exploring one of the most powerful indie game creation tools available - Unity. I’ll be sharing my knowledge and discoveries over a 12 week period. Each week I’ll post primarily on the process of learning Unity 3D along with other topics such as the history of the game engine, the community, and prominent artists/creators.

Last week I discussed the use of Physics & Rigid Bodies in creating a Unity scene. In addition, the application of 3rd person controllers came into play as I started to develop the scene and the 3rd person perspective for the player in Unity.

I’ve been learning Unity using the Lynda.com course, “Unity 3D Essential Training” by Craig Barr as a guide. At this point, I’m a little over half-way through the course,.

Unity Collider Components

Although I briefly discussed the Unity collision system in the last article, I want to go over it in more detail here. Once you have a 3rd person character in the scene (using the Unity 3rd person controller from the free assets pack), you have to determine how to keep the player from walking through walls or props in the scene. This is done by placing collider elements around the items you want the player to “physically collide with”.

It’s not necessary to create collisions for every single game asset in the scene. A better way to simplify the collision scheme in a scene is to edit the collider so it covers a larger area. The walls of the scene, for example, would need to have box colliders on every element of the wall. You can edit the collider and simply drag it all the way across the entire wall. This is done in the Inspector window under the Box Collider element. You can expand or contract the box just like a regular 3D model. And if you want to include the railings in front of the wall just pull the box out enough to cover the railings as well. Now your character will bump up against the railings (and wall) just like you would in real life.

 

Small props or set pieces can also have box colliders around them to prevent the player from walking through them. Again, you can create a single box collider and then edit it to tightly fit around whatever you want the player to collide with.

There are two other simple colliders in addition to the box collider: the sphere collider and the capsule collider. As you can gather from their respective shapes they fit on objects that have a similar shape. The three colliders are grouped in a class called primitive colliders and are not processor intensive. Other more complex colliders like the one you use for the mesh of a 3D object (Mesh collider) are processor intensive and should be used with that knowledge in mind. The Unity manual has an excellent section explaining collision detection.

Sound in Unity

Sound effects have always been one of my favorite parts of media creation. The sound capabilities in Unity are simply awesome. Remember that any component in unity can be attached to a game object. In applying this idea to sound it means that you can attach sound or music to anything in Unity. Plus, you can edit the sound’s properties to control its volume and spacial effects.

In the 3D Essentials scene, I’m working with there is a spilled radioactive goo on the floor. By attaching a gluggy sound to the object and then adjusting its sound field (like a big sphere around the object) you can edit the sound so that it gets louder as you approach the radioactive goo.

Ambient sound or music and also be created in this way by using a blank game object and then attaching the music/effect to it so that it functions the way you want it to. Sound can also be triggered by just about anything in your scene. By skillfully using the sound component in the Unity Inspector you can get your sound to react and respond to any aspect of your scene. In effect giving you complete control over sound in a Unity scene. 

The Lure of the Asset Store

One of the things I love to do is to browse through the Asset Store at Unity. By making Unity free and opening up the coding for the application, there are literally thousands of users who sell (and give away for free) every conceivable asset for Unity game-making in the store. From a complete game to simple scripts you can find anything in the store.

I purchased a set of characters recently who already have scripts and controllers attached to them (see photo above). I also picked up a fog creation effect that I’m going to use in a cemetery scene I purchased last year. The prices are usually very reasonable and Unity makes sure the asset being sold passes stringent tests before it can be sold. Plus, the communitive rating system is rigorous. Members are blunt when it comes to an assets functionality. If something doesn’t work well, creators are made aware in short order.

The downside to the asset store is that you spend too much money! Unity has frequent sales on certain kinds of assets, so if you want to limit your purchases then it’s a good idea to wait for a sale before you buy something, If you have registered at Unity you can put the asset on a saved list so you’ll always remember it. Another great thing about the asset store is that it is very well organized. 

NEXT: Lighting and Baking Lighting in Unity