April 27, 2015

Book review: Thunder Run

I've read the book Thunder Run - Three days in the battle for Baghdad by David Zucchino. It tells the story of the first part in the battle of Baghdad during the 2003 Iraq War. The beginning of that war is a day I remember. In Sweden we used to have a mandatory military service and I was inside of a combat vehicle the night our officers told us that mainly US forces had invaded Iraq. Everyone in our unit was now worried because there was a rumor that our graduation day would be delayed because no-one knew if that conflict would spread. Luckily, that didn't happen.
What I also remember from that time was a newspaper article that tried to describe how the coalition would attack Baghdad. We had practiced urban fighting so we all knew how difficult it would be to attack a large city like Baghdad with a population of 5 million. But as time passed no-one read any more articles about the battle of Baghdad. What had really happened?
A few days ago I found the book Thunder Run and it will explain why no more articles about the battle was produced. The reason is that the mainly US forces decided to use a new strategy to invade Baghdad. The strategy was a series of so-called thunder runs.
A thunder run is a lighting armored strike and the American army has been conducting thunder runs since the Vietnam War. To protect the roads in Vietnam from ambushes, the American commanders dispatched columns of tanks and other armored vehicles up and down the roads. The vehicles moved at high speeds and fired at everything they could see.
Before the American commanders in Iraq decided to use thunder runs as the main strategy, they had the idea to clear Baghdad block-by-block with mainly soldiers while the tanks guarded the outer parts of the city. Before that strategy was called into action the commanders decided to send out a few tanks in a thunder run through the city and to the airport to test the defenses. That thunder run was successful and they just lost one tank. What if they could make another thunder run into the heart of Baghdad? So with just 970 soldiers inside various tanks and other armored vehicles, they decided to seize a city of 5 million people. The tanks made it to the center, but then all hell broke out and that is the story of the book.
The book tells the story with a high level of detail, down to the single mortar round. Moreover, you might also learn a few new things. The art of crater analysis is a technique to determine from where a mortar is fired by analyzing the crater where other mortar rounds have impacted with the ground.
It also tells the background of each solider and what the individual experienced, including a few soldiers on the Iraq side, and the psychology of war. One peculiar story is when a soldier was hit in the chest. What do you think his first thought was? The answer is that he was thinking about how difficult it would be to clean his own tank from the blood. He had been told that they would be required to turn the tank in as clean as they had been when they got them.
One downside with the book is that it only tells the story of the thunder runs in Baghdad. I believe the book should also have told the story of the previous two weeks after the invasion of Iraq. Those battles were not as intense as the battle of Baghdad but it would have been interesting to learn what happened.  

April 19, 2015

Tutorial: How to load and modify a saved animation in Blender

This will be a super-short tutorial on how to load and modify a saved animation in Blender. Let's say you are going to make an animation for Unity. You have a character and maybe two animations, one where the character is doing nothing except moving its head, and one where the character is walking. You did the "doing-nothing-animation" first and then you did the walk animation.

What if you came up with the brilliant idea that the "doing-nothing-animation" should also include an animation where the character is moving its arm. So you want to make a simple modification to that animation. You select the animation, or action which is the name of a saved animation, in the Dope Sheet window. But you will now discover to your horrors that the character is still walking, which is the latest animation you made.

What you need to do is to first select all bones and then open the animation.

April 2, 2015

Unity Tutorial: How to create a seamless audio loop without a clicking sound

Today I decided to add audio to my Tesla Simulator. The cars by Tesla Motors are powered by electricity so I couldn't find a classic engine sound I could download from somewhere on the Internet. So I had to look through YouTube videos to find someone who drove a Model S and at the same time didn't talk. That wasn't and easy task! But I found about 3 seconds of electric car engine sound, which is actually mostly sound from the air and the tires.

I imported this mp3 file into Unity and added it to the cars. But, to my horrors, the sound wasn't looping correctly and it made a clicking sound each time it looped. I made a Google search to find a solution and noticed that a lot of other people had the same problems in Unity with "Audio "click" at loop point" and "Clicking wav loops." But no-one had a good solution. 

After a few trial and errors I found a good and easy solution. What you need to do is to make your audio file "seamless", like those seamless textures. This is how it is done:
  1. Download Audacity, which is a free, open source, cross-platform software for recording and editing sounds.
  2. Open your sound file in Audacity.
  3. With the left-mouse pressed, mark the part of the audio file that will make up the entire loop. The end and the beginning audio-lines should end close to the "zero" line, which is the black line in Audacity.
  4. Copy it and paste it into a new file.
  5. Now we need to make it seamless. Mark a small part of the beginning of the audio (with the left-mouse pressed), go to Effects and pick Fade In. Then mark a small part of the end of the audio, go to Effects and pick Fade out.
  6. Go to File and pick Export Audio.
  7. Drag the exported audio into Unity and you will hopefully not hear a clicking sound each time the audio file loops!