March 30, 2015

Tesla Motors Simulator Update - Gas Guzzler

0 comments
Tesla Motors are just making cars powered by electricity. To sort of show the difference I came up with the idea to add a real Gas Guzzler that is spewing out dirty fumes to my Tesla Motors Simulator. So I recycled an old model from another project. This model is an old Saab 92 from the late 1940's.  You can really see it spewing out black exhaust fumes.


Looks interesting, and maybe you want to crash into it? Then you can drive it here: Tesla Motors Simulator.

Tesla Motors Simulator Update - Destroyable Cars

0 comments
 
No car is undestroyable. This fact also applies to Tesla Motors, who might build cars that are almost undestroyable. When they tested the Model S in a crash-test, the crash-test machine was destroyed before the car. But you can't beat physics, so a car from Tesla Motors will be destroyed if you are driving it into a concrete wall.
 
Because I'm building a Tesla Motors Simulator, I had to add destruction to the simulator. I've earlier tried to use the real physics equations, such as drag force and rolling resistance, in the simulator, but there are no physics equations for destruction. At least not any simple equations that I'm aware of. So I had to cheat this time. 
 
In fact, you can use more complicated equations to crash-test a car in a computer, and then you just crash-test it live to verify the results. When Tesla Motors did this and then they crash-tested a real car, they found a crack in the real car that they hadn't seen in the computer simulation. So they went back to the computer and found the crack in the simulated version - they hadn't just seen it!
 
But back to my simplified simulator. The wheels are currently unbreakable, but I will probably change that in the future.
 

But the glass is breakable, and so are the headlight-covers.
 

Sometimes the destructions is not 100 percent realistic because the cars are using box colliders for simplifications. I will probably try to add a simplified mesh collider and see if the results are more realistic.
 

The transmission is also not destroyable, so no matter how many times you slam into a wall you will be able to continue driving, but I will probably change that in the future.
 
 
Looks interesting? You can test it here (for free): Tesla Motors Simulator

March 27, 2015

Why you should read at least one new book on selling each year

0 comments

According to Fredrik Eklund, the only thing you can't sell is your integrity. What you on the other hand can sell is your product or even yourself in a job interview. So we all need to learn how to sell. If your job is to sell something, which we now know it is, then the rule everyone will tell you is to read at least one new book on selling each year. I've done that. Two years ago I read the book 101 successful sales strategies and last year I read the book The Ultimate Sales Machine.
This year I will read the book The Sell by Fredrik Eklund (he in the image above). Originally from Sweden, Fredrik Eklund moved to the US, had a brief stunt in the porn industry under the pseudonym Tag Eriksson, and he is now a famous real estate agent. 
The other books I've read on selling were more general and maybe more how to sell through a phone or a product. So I hope The Sell will cover other areas (and not just the so-called "high-kick" practiced in the image above) and give new perspectives from the world of real estates. I will write a review as soon as I've read it.

March 24, 2015

Boats, boats, and a little water

1 comments
A few days ago I finished my realistic boat in Unity. I've used the real physics equations, such as buoyancy and wave drifting. It can steer around on the water, even though it needs a few improvements here and there. For example, the rudder is not 100 percent perfect, but that shouldn't be much of a problem to repair.
To market the boat, and the tutorial on how to make a boat in Unity, I decided to produce a 12 minute long video, which I also uploaded to YouTube:


The reason I decided to make a boat in Unity, and teach others how to do it, was that I had watched other videos on YouTube showing computer simulated boats. The main inspiration source was this video:


That simulation was also written in C#, but he is not using Unity. My next step is to build a hot air balloon, because the forces acting on a hot air balloon are actually similar to the forces acting on a boat. So that shouldn't take too long. I will also try to make a more realistic water, but I don't know if that is even a realistic idea because realistic fluid simulations tend to require more computer performance. But I can always give it a try and learn something new while doing it. This is the target:


The video above is showing an animation and not a game. The difference is that a game would have to update the waves 30 times per second real-time, while an animation is just storing the images on the hard-drive...so wish me luck!

March 23, 2015

Why you should play games with Barbie in the title

0 comments
Ubisoft game designer Jason VandenBerghe wanted to understand the psychology behind those who played his games. In 2013, he gave a talk on his findings called Acting like players - Applying the 5 domains of play. I can't embed it, so here's the link

Lessons learned
  • The "Big 5" is a structure of human psychology that is being used by academia worldwide. The 5 are:
    • Openness to experience
    • Conscientiousness
    • Extraversion
    • Agreeableness
    • Neuroticism
  • But Jason VandenBerghe has translated the Big 5 to the world of games. So in the same order as above, the 5 domains of play are:
    • Novelty
    • Challenge
    • Stimulation
    • Harmony
    • Threat - "Ragequit" is included here! It reflects the parts of the game that may cause the player to stop playing when they are otherwise enjoying it. 
  • We need all this because it is important for a game designer to understand what is going on inside the heads of the players. If you have played a lot of games, you will understand a few of the players, namely those who are similar to yourself. But you will not understand all of your players. So you have to leave you own personal biases in your home, and come to the office without them.
  • What you should do is to play games as if you were someone else and try to understand why other people like the games. So play games with Barbie in the title (if haven't already played them)
  • There are different models you can use:
  • Novelty (Skyrim is for fantasy and explorers) Also notice that some players can like both sides, such as building and exploring.
    • Realism or fantasy?
    • Building or exploring?
  • Challenge (The Sims with cheats is for those who are less skilled and play different games by impulse)
    • Easy or hard?
    • Work or impulse?
  • Stimulation (Call of duty is for those who like to play solo and thrilling games)
    • Group or solo?
    • Thrilling or serene?
  • Harmony (World of Warcraft is for those who like team and context)
    • Player-vs-player (just want the other players to lose) or team (be a part of a larger cause)?
    • Context (why should I win?) or mechanics (how do I win?)?
  • Players are not evenly distributed among these categories, even though the humanity as a whole is, because not everyone is playing games. 

March 22, 2015

You should watch this: The Heavy Water War

0 comments
Last night I went to bed late. The reason wasn't that I couldn't sleep or was out late partying. The reason was that I couldn't simply stop watching the television series The Heavy Water War, which is a  six-episode TV miniseries from Norway.
Why Norway you might ask? To answer the question we must first tell what the television series is about. Basically, it tells the true story of the German nuclear program during the Second World War. The main German character is Werner Heisenberg, who was a Nobel Prize winner and also the scientist behind the German attempt to manufacture a nuclear bomb. But to make that bomb, the Germans had to purchase heavy water from a small factory in Norway.
Heisenberg's Norwegian counterpart is Leif Tronstad, who was also a scientist and the main scientist behind the factory that produced heavy water. When Germany invaded Norway, Tronstad fled to Norway and oversaw the mission to destroy the equipment that manufactured heavy water.
To destroy the equipment, the British flew in Norwegian commandos. This part of the story has been told before in the 1965 classic movie The Heroes of Telemark starring Kirk Douglas. That movie focused mainly on the mission to destroy the factory, while the television series also tells the story of what happened in England, what happened in Germany, and what the civilians in the heavy water factory were doing. 

So if you have 6 times 44 minutes to spare then you have to watch The Heavy Water War!

March 21, 2015

Tesla Motors Simulator Update: Unity 5

0 comments
Today I've finished about 90 percent of the work I had to do to upgrade the Tesla Motors Simulator to Unity 5. I've also added a small test version of damage physics, so sometimes you will see that the cars will be damaged if you crash into something. I also added a larger terrain and some obstacles you can jump from.
What's left is fine-tuning, like making the performance of the cars more world-like. I've used the real physics-equations, like drag and rolling resistance, but somehow the top-speed of the Model S is like 150 km/h and not 200 km/h as it would be in the real world. So I have to figure out what's wrong.  Neither the braking distance is perfect.
What isn't wrong with the simulator is the graphics. Unity 5 is beautiful compared with Unity 4, and the performance is also better despite the better graphics. So I've made a small comparison:





March 20, 2015

Surfin' U.S.A. - a tutorial on how to add waves and forces from waves to a boat

0 comments
About a week go I published a tutorial on how to make a boat float in Unity. It looked good and worked realistically, but it wasn't doing much. Today I updated the tutorial with waves and how to make something move because of waves. The answer to that question is called wave drifting. I used a very simplified version which looks like this:

F = 0.5 * rho * g * S * S * n
rho - density of water or whatever medium you have
g - gravity
S - surface area of triangle
n - normal to the surface

And then you just add this force to a triangle that's below the water surface. This is how it looks like:


But that's not it! Next week I will add resistance forces, and then the week after that I will add propulsion, so the boat can actually move around!

Looks interesting? You can test it here.

March 19, 2015

Tesla Motors Simulator in Unity 5

0 comments
I've begun upgrading my Tesla Motors Simulator to Unity 5. It will take some time because Unity 5 comes with a new physics engine, so I have to change a few parameters. I've included the real-world physics equations, such as drag and rolling resistance, so that will save some time. But since you can't simulate then real world because of computer performance, there are still some parameters that doesn't come from physics that needs a little fine-tuning.

I also had to change all materials. The new version with the new materials looks like this:




I also think it is time to add destructible cars, but that will be the topic of another article!

March 18, 2015

How to make race tracks that twist and roll and twirl in Unity and Blender

0 comments
Today I got the question on how to make race tracks that twist and roll and twirl in Unity. So that's what we are going to learn here. I believe the best solution to the question is not to make the track in Unity. You could make it in Unity, but if you are a beginner it is much easier to do it in Blender, which is also a free software. So step 1 is to download Blender.

Now let's make a track path. The good think with Blender is that it uses the same coordinate system as Unity, so 1 unity in Blender is 1 m in Unity. So make a square with the size you want. You can maybe use the cube Blender starts with, click on Edit Mode and drag the small vertices to the shape you want. Don't forget that it also needs a depth, and the depth of the shape you made will also determine the resolution. But don't worry if you mess up, you will be able to change it later.


Next step is to make the path that twist and roll and twirl. We will here use a so-called Bezier curve. So click on Add → Cuve → Bezier. You can edit this path, and make it more complicated by going to Edit Mode, select one vertice, and then click "E" for extrude. With this curve you can also control the angle of your path. So if you want those NASCAR sloped curves, then experiment with the handles (the small lines that go out of each vertice). 


But a path and a track part makes no racing track. We need to connect them. So select the path (cube), go to Modifiers (the wrench on the right side). Now you need to add 2 modifiers:
  • Array modifier. Select Fit Curve in Fit Type, and select the curve in the box below.
  • Curve modifier. Select the curve in the Object square. You might have to select another deformation axis
Everything should now look like this:


The good thing with Blender is that Unity and Blender are very good friends. So to export the track to Unity you just have to save it in the same directory as your Unity project. Then you have to drag it into your scene. The last thing you have to do is to click on the child to the track object, pick the child that's the track (and not the Bezier) and add a Mesh Collider to it. Now the track should be drivable like this:


March 17, 2015

A better way to clear landmines

0 comments
A few years ago I wrote an article on this blog on Creative methods to clear landmines. It included plants that change color when the roots touch a landmine, rats that can smell landmines, and a gigantic ball that explodes when rolling over a landmine. Neither of these solutions have really solved the problem. With the current clearing speed, it will take more than 1000 years before all landmines have been cleared.
Today, while researching how to calculate the mass moment of inertia, I found a YouTube channel called Physics World. Their latest video is about landmines and a better way to detect them.


According to the video, the problem with landmines is not to find them - the real problem with landmines is to figure out what is a landmine and what is not a landmine that could have been a landmine. What the world needs is a way to detect if what could be a landmine is really a piece of scrap. Because clearing a piece of scrap that you think is a landmine takes as long time as it takes to clear a real landmine. The organization Find a better way aims to find a solution to this new problem.   

March 16, 2015

The secrets behind the art of city building games like SimCity and Cities: Skylines

0 comments
If you happen to not be God, and you still want to feel like God, or if you are God and would like to practice your world building skillz, then you could go and grab a city simulator. The most famous city simulator franchise is SimCity. The second release of the game, SimCity 2000, was one of the first computer games I played. It has since then evolved into other competing city building games, such as the newly released Cities: Skylines. That game is according to many much better than the latest release of SimCity.


Despite the criticism, SimCity was still a good-looking game, so today we are going to study the art of SimCity. To help us, we are going to use a talk from GDC 2013 called Building SimCity: Art in the Service of Simulation. I can't embed it, so you have to visit the link.

Lessons learned:
  • All details should have a purpose - never detail for details sake. If there's a car outside of the house, then make sure it looks like someone is currently inside of the house.
  • Almost all objects in SimCity are actually UI elements, which will give the player feedback.
  • Neither add the small humans randomly, all of them should have a purpose.
  • Because of computer limitations, SimCity's many different buildings are actually sharing some textures. 
  • A building with the size 16m x 32m uses up to 256 triangles. To keep the triangle count low, SimCity uses several techniques. For example, it might look like the buildings have interior, but the interior is actually a special texture called "interior mapping" that follows the camera giving the illusion of a real 3d interior. So if you look at the image below, you might say that it has to be 3d, but it's just a plane.

  • A single car has about 310 vertices. The cars are using the same interior mapping technique as the buildings.
  • This is the link to how to make good-looking trees: oceanquigley.blogspot.se/2011/11/lighting-3d-trees-take-2.html
  • Making roads the user can draw and texture them takes hours and hours.
  • Don't forget to adapt colors to those who are color blind, it is not difficult either.

March 15, 2015

Tutorial: How to make a boat float in Unity

0 comments
A few days ago I promised to create a tutorial on how to make a boat float in Unity. I have delivered, and here it is: How to make a boat in Unity. The boat can currently just float thanks to our old friend Archimedes, but I will add more forces in the future, such as drag forces, propulsion forces, and forces from the waves. 

The math and physics iin the tutorial is based on this excellent article from Gamasutra: Water interaction model for boats in video games. It was actually fun to see that what I learned in engineering school is actually working, and the physics and math equations become less abstract if you can play around with them in a simulator like Unity. Who could have know nthat I would use something like cross product again?

Anyway, here are some images from the boat simulator.




And if you want to test the floating part of the simulator you can do it here.

March 14, 2015

Tip of the day: Use Google to host your frameworks

0 comments
Did you know that you can use Google's servers to host your code, or rather the frameworks that improves your code. For example, today I wanted to find out which the best way is to display many lines of code on a website. I believe the answer is Prettify.
Yes, your could download Prettify, and then link your code to that directory. But it's much more simple to use Google to host Prettify. Google's vision is to make the web more faster, so they are more than happy to use their fast servers to host your favorite frameworks. So if you want to display Prettify, you just have to add the following link to your website:

<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>

The same is true if you are using frameworks like jQuery. Just add the following to your website:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

So before you are downloading frameworks to your computer, check if Google is hosting it. It will almost always be faster for your users to download, and it will minimize your workspace.

March 13, 2015

Unity tutorial: How to stop a rigid body from oscillating, vibrating, and shaking

1 comments
This week I've spent a few hours of my life building a realistic boat simulator in Unity. Adding forces and all the complicated math and physics needed was actually relatively easy. But when I added all the forces to my boat, which had a rigid body attached to it, the boat began to oscillate, shake, and vibrate like crazy back and forth.
The first solution I had was to increase the angular drag to something like 50. But this was supposed to be a realistic boat simulator, so increasing the angular drag would make it less realistic. For example, the boat couldn't tilt over with that high angular drag. An unsinkable boat is not realistic.
The next idea I had was to look through all physics book and half of Google to find a better solution. One solution I found in the book Physics for Game Developers was something called roll period and pitch period, but that didn't work either.
Finally I found a single line of code that solved the problem. It is maxAngularVelocity, and you change it to something like this to stop the oscillations, vibrations, and shaking:

boatRB.maxAngularVelocity = 0.5f;

...where boatRB is your rigid body. The final result looks like this:


Tomorrow I will probably write a longer tutorial on how to make a realistic boat simulator in Unity.

March 8, 2015

Why you should solve a problem that solves other problems

0 comments
The best problems to solve are those problems that solve not just one problem, but several other problems. For example, if we find a way to create an intelligent machine, that machine will solve a lot of other problems we have because it is smarter than us. It can build the best car, it can cure cancer (if there is a cure), and it find a way to feed all humans. But building such an intelligent machine is damn hard, so maybe you should find another problem to solve.
One such problem is oil. When two of the original founders of the electric car company Tesla Motors, Martin Eberhard and Marc Tarpenning, wanted to find a problem to solve they decided to solve the world's dependency on oil by building electric cars [Source]. 
Solving our dependency on oil is one of those problems that will solve a lot of other problems, such as:
  • We have to import oil of "troublesome" countries, like Saudi Arabia and Russia. Sweden for example imports maybe 40 percent of the oil supply from Russia. And what is Russia doing with the money? Yes they spend the money on weapons. And a few years ago, Russia decided to practice targeting a Swedish naval base with nuclear weapons. Is it really a good idea to pay another country money and get that response?
  • Another problem is that oil causes global warming.
  • We are also going to run out of oil anyway, so we have to solve this problem in a not that distant future.
  • The number of cars increases each year, so even if there is an endless amount of oil, we can't supply all new gasoline cars with the oil we are currently pumping up. 

March 7, 2015

How to clean your inhouse air from benzene, formaldehyde, ammonia and much more

0 comments
Today is a big day because today I bought a new living creature to my apartment. It wasn't a dog, it wasn't a cat, and it wasn't a rat - it was a Spathiphyllum wallisii, otherwise commonly known as Peace lily, White sails, or Spathe flower. 
A few years ago, when I decided to buy a new plant to my home, I did some research on the Internet, and wrote a small article on the results: How to hack the air. The article has since then become one of the most popular articles (I suspect people are searching for how to hack wifi and instead find my article on house plants). According to that article, the best air-cleaner is the Peace lily. The tests were made by NASA when they had the idea to send plants to space. What the Peace lily will clean is:
  • Benzene (from paint and tobacco smoke)
  • Formaldehyde (from furniture and  tobacco smoke)
  • Trichloroethylene (from paint removers)
  • Xylene and toluene (from your computer)
  • Ammonia (from detergents)
  • The Peace lily will also increase the air moisture in your house
  • ...and it can live in the dark
...and all this for like $16 per plant. They are also quite esthetically pleasing:

Source: Odla

I might sound excited, but hey it's #blogg100 and I didn't have anything else to write today! 

March 6, 2015

Are you really stupid?

0 comments
I believe it is common to sometimes feel that you are stupid when you are into engineering, because engineering is often abstract and you have to put many hours into solving a wide range of problems. I felt stupid yesterday when I couldn't simulate waves in Unity. But after a few hours I came up with the solution to the problem (thanks to our dear friend sin(x)).


Today I found this tweet:


This message in the tweet is true. About a year ago I had no idea how to even make the boat in the image above. But today it took about 1 hour to make the boat in Blender and import it into Unity, and then add the water from yesterday. So feeling stupid is actually good because you are learning something new and keep improving your skills.

March 4, 2015

The easter bunny came early this year with Unity 5

0 comments
About one year ago I found a cool piece of software called Unity. In Unity you can make games, I believe the game Angry Pigs was made in Unity, and you can also make simulations, like my own Tesla Motors Simulator. The good thing with Unity is that you can focus on building your product instead of first focusing on building a game engine and then your product. This will obviously speed up the process and I don't even know if it is realistic to learn both in a short amount of time. Earlier I considered this cheating (to not build everything yourself), but hey, even Minecraft used libraries built by other developers and they turned out fine.

But back to Unity. There are basically 2 competing game engines: Unreal and Unity. A few days ago, Unreal revealed that their engine would be free to use, and yesterday Unity revealed that their new engine, Unity 5, would also be free to use. Unity had earlier 2 versions, one free with like 90 percent of the functions, and one pro version that you had to pay something like $1500 to get. But yesterday they released the pro version for free (But you have to pay Unity if you make money).

The first thing you notice in Unity 5 is that everything from the beginning looks better. The "hello world" of all game engines that also can handle physics is to build yourself a tower of cubes and then destroy the tower with balls. This is how it looks like in Unity 5:




Even though the images above look like they are still images, you can actually fly around. So I'm really excited what I now can do to improve my Tesla Simulator (which by they way is completely broken after the update because Unity changed a few of the physics calculations). And if you want to try out Unity yourself, there's a lot of tutorials on YouTube and on Unity's own site.