Pagina's

woensdag 18 januari 2012

Gapless looping MP3 music in Unity 3D

Recently I have been struggling with my background music. As it appears MP3 music does not loop very well. Natively MP3 sounds have a little space at the start and end of the track.
I thought that when you add a MP3 sound to your game, the new Unity setting called 'Gapless looping' would solve that for you automatically.

The problem in my case was that the property was disabled.

After searching for answers on Unity questions and answers, Google etc I have found the solution myself!

The trick is to export your music as WAV. Meaning that it will be added to Unity as an uncompressed audio file. Next, select the audio file and watch the properties in the inspector. As you can see the drop down shows WAV and most of the other options are grayed out. Now, select MPEG from the drop down. By doing that we are telling Unity to compress the WAV file.
Watch what happens with the other properties: they become enabled!
Next, select Gapless looping and the other settings. If you are using the file as background music you might want to set priority to 0 for instance to prevent the sound from being swapped out. Also it probably doesn't make sense to have 3D background music as the volume and panning does not apply to the position of your listener.
Finally click Apply and Unity will start creating the MP3 file for you. Add an empty game object to your game, add an Audio Source component to it and select the Audio clip. Make sure looping is enabled and start your game!

The music should loop perfectly. So to summarize: don't import MP3 files into Unity but instead import WAV and let Unity create the MP3 for you. That way you can create nice looping background music.

Enjoy!

maandag 16 januari 2012

Game music

There we go: a new fresh set of game music ready to get integrated into my forthcoming game. Which actually means that I am neeeeeearly done. :-)

Enjoy:

Meet the masters - game music by Serve Hermans

woensdag 11 januari 2012

Book review: Unity 3.x Game Development by example

It took a while but now I have finished reading the book Unity 3.x Game Development by example - beginners guide written bij Ryan Henson Creighton.

The subtitle says: A seat-of-your-pants manual for building fun, groovy little games quickly with Unity 3.x and must admit that this book definitely gives you a nice start.

There are several reasons why this book might be useful for you where other books about Unity development are not:

  1. the nr. one reason for indie developers to fail is that they set their goals to high. Often, like me, you are developing on your own. Trying to build an epic open world game is just one bridge to far and you will need to concentrate on something you can finish and discover the game mechanic which is core to your game. The author spends a great deal on this and shows you various games and their game mechanics. When I read the first chapter I was already convinced that this book would focus on the core building blocks but started to get a little worried if the games in this book would be too simple. Luckily I was wrong.
  2. The second reason is that most books and tutorials contain advanced examples where the code is long. The author instead focusses on short scripts and explains them very well and with a lot of humor too! Meaning that you will develop a nice 3D game where you have seen all of the script but without the need to explorer a 300 lines of player controller script. The same is true for the chapter that deals with Unity. It is right to the point where additional GUI elements in the other chapters when there is need to work with them (like the Animation window)
  3. The third reason is that most 3D games are rather complex in terms of maths. For beginners, this is terrifying. You don't want to understand everything right from the start. Of course, movement and rotation will be explained but you don't need to lets say do some raycasting to detect if the laser beam hits the player or discover who is in line of sight.
  4. The fourth reason is that when you have a good game mechanic you are probably a developer who would like to start coding. You don't have any graphics yet still Unity provides you some primitives to work with. The author is doing the same, he starts with a good game mechanic: keep the ball in the air using a stick. But then after some time you would like to replace it with real 3D graphics someone (or yourself) provides. Maybe after some time you would like to use the same concept in a different game with different 3D graphics. Well, that is exactly how the book works. It will show you how to transform the core concept into a game where a heart will be bouncing on a tray and the nurse is running through the hallway. It also shows how to reskin a game from something where a guy is trying to catch bombs and steins into a game where a spaceship is avoiding enemy ships and can fire some bullets as well. This is very good to my opinion. Reskin the same game into something totally different will show you how to reuse scripts which will definitely speed up game development in the end.
Having giving you the main reasons to read this book I can only add that it is a funny book! The author has its own style with lots of humor making everything very readable. In the end I finished  this book mostly when reading it in the train. Which tells you something about the fact that you don't need to sit in front of Unity with all of the assets loaded to understand it. Of course, it would be better when  you actually try things out yourself but if you already have played around a little bit with Unity than this will  work as well.

What is missing? To be honest, this book is a good start but when you want to develop a game you will need many levels. And that piece is missing. I am referring to the piece called the game engine responsible for loading levels and keeping track of the main game properties like nr of lives left, score etcetera. Although you can read about it on this blog. ;-) Shameless plug. Nevertheless the concept of scripts which will not be destroyed when a new level is loaded is a real necessity.
Also, I would have been recommending the use of the iTween library for easy animation like moving an object smoothly from A to B. iTween is still for free and very useful.

Summarized I love this book! If you are a beginner then this is a MUST read! When I started on the iOS with Unity there was a tutorial for a desktop game and finally a tutorial for iOS as well but that took some time. Even the Penelope graphics were using things like light baking, multiple character controllers etc. Good stuff but way too complex for a beginner.

Grab the book!


Sample chapter:



zaterdag 10 december 2011

Unity books

I am currently reading two books on Unity game development:

* Unity 3 Game development hotshot
* Unity 3.x Game development by Example Beginners Guide

 Visit these links for more info:
http://www.packtpub.com/unity-3-game-development-hotshot/book
Or
http://www.packtpub.com/unity-3-x-game-development-by-example-beginners-guide/book

As soon as I have finished the first I will write a review on this blog.


woensdag 23 november 2011

Unity Remote is slow and choppy

Today I was testing my iPhone game using Unity Remote and it was choppy and slow. Some people suggest that you turn off the Show Image feature on Unity Remote which disables the graphics output on the iPhone and can only been used as control testing. I found this not very useful as you don't know where to put your finger if you don't see anything. So I tried a different solution which worked pretty well:

Turn off Bluetooth on your iPhone device and bingo! The response is back to normal and it has solved my issue.

woensdag 19 oktober 2011

Unknown identifier after upgrading Unity

After I upgraded Unity today I received all kinds of compiler errors containing the message Unknown Identifier.

At first it seemed that this is caused by the fact that my project for the iPhone game consists of Javascript .JS files and I am also using a Plugin called iTween which is build using C# .CS files.

According to this article: http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html there seems to be a particular order in which files are compiled. Someone on the Q&A site even suggested to move the iTween plugin to a different location outside the standard assets folder. After I moved the plugins folder I received errors related to iTween types not being denoted. After some research I discovered that I started to Google first and then think instead of the other way around.

Although the Unknown Identifier issues were not mentioned in my previous version of Unity and  the game did run just fine, the new version apparently has a more strict way of compiling. Suddenly I discovered that each error was in fact an error!

There were variables which were not declared in the scripts. I also made a typo leading to the same error as the variable was declared but due to the typo it failed.

Summarized, examine each error first before starting to Google your question. The new version is more strict and you probably have to update a couple of statements first.




woensdag 15 juni 2011

Finally made it into the second chapter of Meet the Masters

The iOS game I am currently working on is all about the great and famous painting masters from long ago. Of course, the main objective is still to roll your ball to the finish but it doesn't mean you can enjoy the paintings.

Every painting consists of 15 levels and the game play changes dramatically with each painting. So, take for instance Rembrandt where the main elements are circles: thick, thin, wide open, almost closed etc. They move, rotate, spring and bounce etc.

However, today I have started working on the next 15 levels for a new painting from Raphael Sanzio. The main elements here are labyrinths! Labyrinths which rotate slowly and have all kinds of nasty moving elements inside them.

Take for instance the one you see at the top. It looks fairly simple, but the reality is, the labyrinth rotates completely, meaning that even the finish doesn't stay on the same spot. Next to that, the biggest prism starts moving downwards, hence changing the way you have to move through the labyrinth.
I like it a lot and already I finished three levels for this painting. And I have many more primitives ready to join the scene.

For the third painting I have plenty of ideas, the main element there will be height. So up we go and instead of trying not to get hit, the main objective becomes not to fall down. So, stay tuned as things are progressing fast now for the iPhone game Meet the Masters!