Fast Gear – Week 9

So this is the final week. I have been working on some different things throughout the week. I have tried to balance the sounds better. Mostly we have worked on getting the positions of the cars in-game. We can now differentiate the cars in the race and see who is first, seconds, third and fourth. This was supposed to be done earlier but we ran into some issues with the code and we have been trying to figure it out the past two weeks. We finally solved it and can now move on to how the positions will affect the game.

If the player is last we will set the cars to have a lower speed in order to make it so that the AI does not drive away from the player in order to make it feel more competitive. It was not a good feeling when you were last and there is no way you can catch up with the other cars. We also made it so that the AI will have a higher top speed if you are first. The purpose was to give the racing a more intense sense of racing, that you are never safe and if you crash it is not too late to win. This makes it much more friendly to new players but still keeps the difficulty for the players who have raced before.


Fast Gear – Week 8

This week I have been working on sounds for the game. I would have liked to start earlier than this but other “more” important things have come in the way. I say more important but in reality sounds are very, very important for a game. I added three different car sounds to our car, one idle, one for accelerating and one for when you have reached the maximum number of gears. Every time you go up a gear the same sound plays but with a different pitch so it gives a feeling of acceleration.

I have also added music since we aim for an intense feeling when you are playing. The music comes from an independent music producer that we contacted a couple of weeks ago to ask if we could use his music. Audience sound was also added along with minor ambience. The audience is cheering in the beginning and when you drive by them along the track, this gives an intense atmosphere which we were looking for. The ambient sounds right now is just in the harbor which you drive by one time each lap with calm ocean sounds.

All sounds are to give the right atmosphere that we are looking for. Intense and exhilarating. I want to add more sounds but that can result in a mess, where different sounds play all the time. It is a fine line I have to walk to balance the sounds with different volume and pitch.

Fast Gear – Week 7

In order to move the AI they have a force applied to their rigidbodies in the z-axis that pushes them forward. We use a property of the rigidbody called drag, which is how much air resistance the car will have when forces are applied to them. It is a scale from 0 to infinity where 0 is no resistance at all and infinity makes them unable to move. We are using drag to make the cars stick to the road better and the cars have their own value of drag so they have a different feel.

The problem this is causing is that they become so heavy when drag is applied and the player car can not push them out of the way. I tried removing the drag and give them each a physics material which is used to adjust friction between different objects. This was even worse and made the cars very slippery or too sticky, there were no in-between which is why I decided to go with the drag instead.

In order to make it seem like the player can push the other cars out of the way I made a script that checks if the AI has been hit by the car and then calculates the angle between the collision point and the player. We get the opposite Vector3 and normalize it and then add force in the direction of the impact. This will give the AI a nudge when it gets hit by the player. We will also implement so if the AI is directly behind the player they will slow down so they do not push you into a railing which can be very annoying.

Fast Gear – Week 6

This week I have been fixing some small hiccups that occur with the AI. For example when the frame drops I talked about in an earlier post appears and I have no idea why. Luckily this time it was relativelty simple to investigate and find the problem. In order to understand the problem you first have to understand the basics of the A* algorithm. A* searches among all the possible paths it can take to reach the destination and chooses the one with the smallest cost. f(n) = g(n) + h(n) is the equation where n is the last node on the path, g(n) is the cost from the start to n and h(n) is a heuristic that estimates the cost of the cheapest path from n to the goal. This might seem a bit confusing, because it is. The problem I had with this was when we swapped tracks to a new one. This made the waypoints which the algorithm is calculating towards move out of the track and onto the “ground”. I have it set so that the road costs nothing to travel on but the ground costs 1000. This makes it so it wont go over the ground since it costs too much. When the waypoints were outside the track it had to do a lot of calculations with very big numbers and that is why it caused a spike in memory.


This week I have also been working on a FOV(Field Of View) for the AI. It creates a circle around the object and then you can change how big the FOV is going to be. If another object is in that FOV it will sense it and I can then tell it to do something. We have not yet figured out exactly what we want the FOV to do as of yet and I imagine that I will be working on that the next week aswell.

Image result for fov

Field of view example.

Fast Gear – Week 5

As I mentioned in my previous post I have been working on the waypoints and the AI practically throughout the week. I have made some progress and the frame drops does not seem to be noticeable. The problem was that for 21ms the pathfinding for the units allocated 18MB memory but now I have reduced that to only 8.9MB which is a notable difference.

The problem seemed to be the threading which you can implement so you can have different calculations parallel with one another without interference if I understand it correctly. Since I have not done something like this before in a project it caused an issue. But the threading is now gone and the frame drops are considerably lower.

I also changed some things with the target. Instead of the different AI’s using the same target I assigned them their own. It is now a list of different target locations that check if the assigned AI has collided with them and in that case it moves to the next index in the list. I did this incase one AI came to a waypoint faster than the others. There was a small jerk in the other AI as the may have been in the middle of a turn or colliding with something, now they can take their time with the track without relying on each others targets.

Next week I am going to be working on making my own controller/physics for the car instead of using the prebuilt, which has helped during the prototyping and alpha but it is a lot of code which we do not know much about making it hard to troubleshoot.

Fast Gear – Week 4

Up until this point and probably for a couple of more weeks my focus have been on doing the AI(Artificial Intelligence) for our game. The AI is not that complicated as of right now. It has a road which it follows using A* which an algorithm for calculating the fastest way to the goal. The area surrounding the road is not made out of the same material so it has a higher value, meaning it costs more to drive on it. This makes it so the AI will try to keep itself on the road as much as it can. I have also added physics to it so that it looks more realistic when it drives around the track. Also if the AI does get outside the road I made it so it has a bit more drag which makes it go slower until it gets back on the road.

During the playtest we had this week we understood that the AI needs more testing against players who are not used to playing racing games. It was fairly easy to keep up with and beat the AI for us but for the ones playtesting it was very hard, they hardly ever saw it after the start.

For the upcoming weeks my focus will be on optimizing the AI. There is currently a spike in memory usage when it is calculating its new route which causes the frames to drop down to around 30 for half a second. Right now I am not sure what is causing it so this is a priority for me and the group.

uppladdad 2017-4-13 klockan 11:10:23.png

What you see in this picture is the A* algorithm. The red and white squares are cars and the black dots are waypoints which it tries to follow as best it can. The white lines are displaying when they should turn.

Hello and welcome

Welcome to my blog about game design and programming. This blog is an assignment in my course, Big Game Project. The goal is to have a finished game in approximately 2 months. During this process I will write in this blog and talk about my design decisions and programming.

We are seven people who will be working on Fast Gear. My role in this is lead programmer, which means I will oversee the work of the other programmers, coordinate our efforts and set a code standard.

So you might be wondering what our game is about? The short answer is that it is a singleplayer vs ai racing game. It is not only what you do on the track that matters, you will also be judged by the ai off track during press conferences. Depending on your actions they will behave differently towards you.