Simple Sound Implementation in Unity3d

This is Eric Nielsen with you today on the topic of sound implementation in Unity3D. Besides composing music with Catherine Grealish, I’ve also taken on the duty of adding the music and sound effects in the game. For my part, I have a technical background that has given me some of the groundwork for this task, including extensive work in developing databases, end user tools in Visual Basic, Visual Basic for Applications and various other info-techie endeavors in past careers, so jumping into game audio implementation has been fun and also a little challenging. Fortunately, Unity3D makes the basics super simple, and there is an abundance of examples as well as middleware tools available, some of which we are evaluating for future iterations of the game (more on that in a later post).

To demonstrate the simplicity of implementing sounds in Unity3D, I will outline a quick three step how-to for adding a “one-shot” sound to an event, my example being our main laser cannon sound. One thing we must have in any project with sound is one Audio Listener object, which is by default associated with the Main Camera.

Our first task is to add the sound asset in Unity. Sound files can be placed in the game’s project folder in Assets : Resources : Audio : Source using the Asset : Import New Asset menu item or via the operating system’s file manager. Either way, Unity will recognize them as new assets.Adding Assets

Audio SourcesThe second task is to associate our main gun sound to another game object, in this case, our Player’s fighter ship. We’ll create an Audio Source object within the Player object and then drag a sound file to the Audio Clip field of the new Audio Source object, as shown in the Inspector.  By default, new sounds in the Audio Source object are marked as “Play On Awake” which we will uncheck for this sound.

MainWeaponVariableThe last step gets us into the code. One script in particular, in this case our “Firing” script, is also associated with the Player object, where we can add the new Audio Source variable. Here it is called “MainWeapon,” and the AudioSource.play() command to play that sound when the weapon is fired, in this case we type in MainWeapon.play(). In our code, we’ve added an “if” statement to make sure we’re not trying to play a variable that has nothing associated to it.

PlayAudioSource

Other functions such as AudioSource.playOneShot(), or  Pause and Stop can expand on this basic functionality, and any sort of “round-robin” or randomized clip rotation, or even dynamic mixing of individual sound elements, will either require extra coding, or the use of a middleware tool to take on that workload.

And there we have it – our main gun sound will blast away at the enemy! Stay tuned for more about our future iterations on music, sound implementation and more.

Advertisements

A Note from the Music Department

Catherine Grealish here, composer and co-producer of Ancient Aliens: Severed Skies.

I am very excited to be co-scoring ZeroPoint Studios’ premiere game with fellow composer and dear friend Eric Nielsen.

It is always great to have the opportunity to work on a fun game with a great team of Indie developers but there are two major reasons why we’re particularly excited to be working with ZeroPoint Studios.

Firstly, we were brought on very early in the timeline. This way we had time to workshop and develop ideas and receive feedback while everything else was also being developed. It has made the scoring process a lot more organic and we really feel like part of the team. Often you are brought in so late to a game that it is a mad dash to the finish line. The concept of bringing composers in at the beginning was reaffirmed the other day when the creative team of Blizzard participated in a panel discussion organized by the Academy of Scoring Arts. It was exciting to hear them speak to how important this is while being part of an indie game studio that had also embraced this concept.

Secondly, the music we are developing for Ancient Aliens is a unique challenge. The game is set in ancient earth civilizations like Egypt and producer Evan Hembacher had the idea of integrating ancient indigenous instruments into the score, sounds which which would then merge with more traditional gaming space-shooter soundscapes. Eric and I had a lot of fun researching indigenous ancient instruments, scales and soundscapes and worked on how to make the integration process natural and exciting.

In future blog posts Eric and I will be taking turns sharing with you specific aspects of the scoring process which we find fun, exciting and challenging. We are loving this journey and we hope you will stay with us.

Here is a sample of some of the music Eric and I have been creating for the game. We would love to hear your thoughts!

Unity Performance on iPhone: Tech Crunch Party, Poly Counts, Audio, VR, and Object Pools in Ancient Aliens

Last night I had the wonderful opportunity of attending the TechCrunch Virtual Reality Meetup at the Mondrian Hotel Skybar in West Hollywood. It was a great mixture of gamers, entrepreneurs, models, and fashionistas all playing a variety of early stage VR games and multimedia experiences.

I wandered around talking to VR fans and developers, played some cool games, and saw some neat video applications. Andrea Hawksley of the San Francisco based eleVR showed me a stop-motion video animation that looped every 5 or so seconds. The catch was that you could seamlessly look around 360 degrees on all axes, and if you looked up you saw a flying monkey resemblant of Zoboomafoo. Check out their work at elevr.com.

A dodgy photo I took of someone playing Darkfield VR.

A dodgy photo I took of someone playing Darkfield VR

I also had the opportunity to meet a disciplined and talented programmer from Germany named Mark Schramm. I had a long conversation with Mark about the production process behind his soon to be Kickstarted game: DarkfieldVR (@DarkfieldVR follow Mark on twitter, you will not regret it). Playing the demo of Darkfield I quickly realized I was experiencing perhaps the most polished, best game I have played on VR to date. You get into a cockpit in a spaceship and can see a 3D model of a helmet on your head. You then fly around a Star Wars like space battle blasting away at enemies, using your head rotation to help aim your weapons. Mark has been working on his game for a year and a half with a 3 man team (college friends) and hiring other personnel on a small contract/need basis. They develop in Unity 3D and utilize the 3D asset store extensively, “though we heavily retexture and modify the assets we use to fit the style of our game.” says Mark. Mark also said that he is not looking to expand his team just yet, and prefers to finish Darkfield with his friends to allow for efficient collaboration and focused creative vision. Mark is doing it right. Darkfield looks like a AAA title, and the fact that it is made by a 3 man team shows that if you can utilize the power of platforms like Unity 3D and the 3D asset store, now is time to start making the games you want to make without waiting for the approval and endorsement of a higher power.

Before I move on, I must add that Mark is also programming an advanced Neural Net AI for the full version of DarkfieldVR which will be a cooperative online game like Left4Dead. When they launch their Kickstarter in a week I highly encourage anyone remotely interested in game development to check it out and contribute:

https://www.kickstarter.com/profile/VRbits

A Darkfield VR Screen Cap

Now on to the brief technical update on Unity Mobile Performance with the game Ancient Aliens: Severed Skies that I am developing with ZeroPoint Studios. We have been running early stage iPhone tests and have not run into any performance issues thus far. After talking with Andrew Goldstein of Otherworld Interactive last night, I learned that the biggest performance draw in Unity mobile games is by far and large poly counts. I played one of Andrew’s first person 3D interactive iPhone VR games which had incredible binaural sound design. I asked him if the complex audio had any sort of effect on the performance. He noted that they did all of their audio in Unity and the performance draw was negligible in comparison to poly counts. I will take this into account as we move forward implementing sound design in Ancient Aliens: Severed Skies.

Testing VFX in Ancient Aliens with Unity3D

Testing VFX in Ancient Aliens with Unity3D

Screen Shot 2014-09-19 at 1.56.29 PM

Using an Object Pool in the Inspector

Because Ancient Aliens: Severed Skies has a lot of bullets, explosions, blood, and particles, we are using a technique called Object Pooling to help with performance. In Unity you store a pooled object as a prefab in the deactivated state – this is because instead of destroying/instantiating pooled objects (which can be a costly in high concentration) you simply deactivate/activate them later in a new position. At the beginning of each level you spawn a bunch of pooled objects so that all the heavy lifting is over with and you can easily summon large volumes of objects for the rest of the level at a low cost.

That is all for now. Do not forget to follow @ZeroPointLA on twitter and stay updated with our progress on Ancient Aliens: Severed Skies.

Cheers,

@Pablo_LeonLuna

Ancient Aliens: Environment Art

Today I wanted to share some of the environment art the team has been building for Ancient Aliens: Severed Skies. We are really fortunate to have nine (yes nine!) artists workings on the project – 3 experienced industry vets and 6 art school grads who have been eager to practice their skills on a serious project. I’m thrilled by the working relationship the artists have developed – progress has been fast and steady over the last month under the solid leadership of Stephen Philpott, our art director.

Egypt Aliens

Stargate-esque reference art

southpark_egypt

South Park – my favorite Egypt color reference!

While the alien spaceships are definitely the keystone on which the game puts most of its aesthetic weight, building an environment that is true to the setting, which includes a variety of ancient civilizations (in this case Egypt), will really clinch the tone of the game.

Buildings_rend01

Egyptian Buildings – Untextured WIP

Egypt Building - Textured WIP

Egypt Building – Textured WIP

For the upcoming demo version of the game, we are using the UV scrolling technique to bake the 3D environment onto a 2D texture, and have that image scroll downwards to simulate the player’s upward movement. As such, the environment assets need only be readable from a distance.

Market Stall WIP

Market Stall WIP

Above View WIP

Above View WIP

However, as with many aspects of this project, we are taking a high-to-low fidelity approach; that is, we are building high fidelity assets (within reason) and baking them down to smaller files and textures as needed. This will allow us to easily upscale if we choose to port to PC or consoles down the road. There are other advantages as well: we can potentially use the assets in cut-scenes or during story beats between missions, and we are freed up to have the player fly very close to the ground from time to time.

Environment Art

Egyptian Building WIP

I hope you’ve enjoyed seeing these early works-in-progress. I’ll keep posting about the progress of our environment art as it comes together into a cohesive backdrop. Expect to see vast deserts, sprawling cities, quaint villages and ancient relics, including of course the iconic pyramids, the Sphinx, and other recognizable landmarks. We plan to add an alien twist to these locales, of course: it was Ancient Aliens who helped build them after all!

Next up: spaceship art!

Unity Scene Diff Tool

Greetings fellow Unity developers,

As you may have come across, text diffing and merging Unity scenes is not so easy.  Having a Unity scene be diff-able and merge-able is necessary for multiple team members to be able to edit it at the same time without losing changes.  Most teams either deal with this by letting only team team member at a time edit the scene file, or by buying Unity Pro ($1500).

Even with Edit->Project Settings->Editor->Asset Serialization set to “Force Text”, here’s the type of diff you can expect after changing a single value in your Unity scene.  The scrollbar shows how long the text is!:

before

Some solutions to this have been made, and sold on the Unity Asset Store.  My team tried two of these solutions.  However, neither of them just worked out of the box, and they were both extremely clunky.  It would have been more work to get these solutions to work for our team.

So, I figured out how to fix the problem with a simple Python script.  The Unity text file has lots of entities, which look like this:

— !u!196 &5                  <– (THE ENTITY TAG)
NavMeshSettings:
  m_ObjectHideFlags: 0
  m_BuildSettings:
    agentRadius: .5
    agentHeight: 2
    agentSlope: 45
    …
In scenes of moderate to large size, Unity basically randomizes the order in which it saves the entities.  So my Python script just sorts the entities based on their tag name.  Afterward, you get a much simpler diff:

after

The script was surprisingly easy to write.  Since it’s in Python, it works on both Windows and Mac, which is important since some of our team works on each platform.

Hope this tip works for you!

Aaron Smith
Chief Technical Officer
ZeroPoint Studios

September Crunch

October is a big month for ZeroPoint Studios, and September will be full-crunch preparing our first game, Ancient Aliens, for upcoming events. The first big benchmark for our studio is IndieCade – more a celebration of indie games than a professional conference, IndieCade has always been a really fun, laid back opportunity to talk games with fans and devs alike. This year’s goal is to have a working level of Ancient Aliens in a presentable state, so that I can start showing it to people and build up a bit of hype. For the first time I will also be attending the indieXchange summit, which is advertised as a matchmaking opportunity for indie devs (it sounds good in theory – this year I’ll find out for myself if it’s worth the steep ticket price!).

Our goal is to have 6 enemies ready for the demo level – 3 “organic” ships, similar to the Zerg from Starcraft, and 3 “tech” ships, aesthetically kind of a hybrid of Terran and Protoss, to continue the analogy. Each enemy can be absorbed by the player ship, modifying the player’s weapon in a unique way, kind of like Kirby’s inhale ability. Our game allows two of these modifications to stack on top of each other, creating an interesting design challenge in determining how these mod combinations should function. Making this feel fun and intuitive will make or break the game, in my opinion, and peoples’ reactions during IndieCade will be a very useful test-case to see if we are on the right track.

Later in October is the Gaming Insiders summit in San Francisco – a trip that seems well worth taking as there are some great guest speakers on the docket. This will also be an opportunity to show people an even more honed version of the demo level, and hopefully get some expert critiques (my assumption is that only serious devs will be attending said event).

To close out the month is the Indie Game Festival submission deadline (Oct 19). Ours will of course be a work-in-progress, but submitting will be a great exercise in creating a holistic package, a vertical slice of gameplay that exemplifies what makes our game fun and different from other scrolling shooters.

Stay tuned to find out how these events went down, and also to hear more about the next huge company goal: the Ancient Aliens Kickstarter!

And of course, much love to my amazing team for carrying the standard forward every step of the way. Everyone has gone above and beyond with their professionalism and quality of work, and continues to do so on the promise of a dream. This project wouldn’t exist without them. Thank you guys!

Evan
Creative Director
ZeroPoint Studios

ZeroPoint Business Cards

                         ZeroPoint business cards came in the mail! Huzzah!