Game Development Update #3

  • January 20, 2018
  • Paul Sokk
  • 10 min read

Project Number 2: Mechanical Difficulties has changed quite a bit from the last time I wrote a development update post. This current one, in fact, might seem a bit confusing if you didn’t read my last post, where I wrote about the game’s core features. To sum the mentioned post up – I’m creating a game that is a hybrid of RTS and FPS style. It will play similarly to RTS in that you can build a city, gather resources and train an army to defeat the enemy base, but it will all be in the first-person view.

Optimizing

In the last development update, I provided a download link for the game and got some feedback from you. I found out that the game had performance issues. The most noticeable – mouse lag. That means, you moved the mouse, but the player turned a few moments later. The older/slower the computer, the laggier it was. So I figured it had something to do with the game’s graphical requirements. It came as a surprise for me because it never happened on my computer. The game just didn’t require enough processing power for my beast of a machine to even break a sweat. 🙂 Yay for my computer, boo for my development skills. Luckily I had my laptop, that has pretty low-end specs, so I could test the game there.

When it comes to games, and Project Number 2 especially, I want as many people as possible to be able to play it. No matter if they have high-end hardware or not. That is why I wanted to optimize it. Optimizing games means finding the part of it that requires a lot of computing power and then rebuilding it to work smarter and more efficiently. Not all parts of the game can be optimized tho and might have to be just turned down on quality instead. That may result in some parts of the game looking slightly worse, but these decisions are largely part of the everyday game design.

Playing a detective, trying to find out what made the game slow took a long time for me. I had figured out that selecting lower graphical settings made the so-called lag smaller, but looking around the level I just couldn’t see anything graphically taxing. It was all just white boxes with some of them having prototyping materials slapped on them. So I spent several days going over and tweaking mouse input and player controller to maybe find a problem there, but that didn’t make it better. How can it be, that I could play a visually appealing racing game on my laptop fine, but can’t play a simple shooter where there are minimal effects and only white boxes as the level.

GIF

A large effect on performance factor in games are lighting and shadows. Usually, a large chunk of shadows are pre-rendered (pre-calculated). Looking at my lighting setup it turned out, I had set up my level quite badly. I didn’t let the game pre-render lighting and in many ways, it couldn’t. I had to reconfigure the lighting and replace the white boxes in the level to make it better. As funny as that sounds, the white boxes made the game slow. 😛

So I ended up with a whole new level that looks 10 times more fitting. I had planned to bring this kind of an island map into the game anyway, so it was kind of an excuse for me to do it now. The new map has two sides for each team’s base, just as a 1v1 RTS game would have. It also has one type (oil hole) of resource points already placed on each side.

GIF

Player Movement

Partly because I was looking for mouse input errors and partly because I heard criticism, I decided to redesign the player movement. Previously the player movement was slow and floaty and didn’t play like other twitch-shooters such as Call of Duty or Battlefield. Doing research, I learned that jumping in-game doesn’t usually apply to real-world physics. What is correct according to gravity calculations usually seems floaty in games. That is because games have always used unrealistic jumping styles that just fit the certain gameplay.

Old jumping was floaty and had one certain height

GIF

New jump is faster and height depends on how long you hold the button

GIF

Weapon animations

A good first-person shooter for me is nothing without good looking weapon animations. Adding slight weapon rotating when turning with the mouse was the first “animation” I wanted to add to the weapons. It was just a little something I came up with to add realism to movement. Yet when I finished I realized how much of a difference it made in the game.

At first, I managed to mess it up multiple times…

GIF

And then got it working perfectly…

GIF

Adding actual hands to the weapons, animating them and fitting them in the game had the greater effect of course. But it was also a greater pain in the butt. That was in consequence of the program (Blender), where I created the models and animations being different from the engine (Unity) where I create the game. That resulted in a lot of tweaking and back-and-forth switching to make everything look the same on both programs. In the end, I got it all working and managed to get all weapons’ shooting and idle animations into the game.

GIF

Well, now it looks like a first-person shooter to me.

Building

As mentioned in the previous blog post, Project Number 2: Mechanical Difficulties revolves largely around building your own base. I envisioned the building process being something similar to Minecraft, where you look somewhere and click to build. But similar to most RTS games, where building takes time.

So I built a system where the player can see a projection of the selected building in front of them. That projection would look like a hologram – half transparent, just so the player can visualize what the building would look like in the end.

When the player confirms the location of the building, a foundation is placed on the ground and the building process can begin. In the finished game, there would be drones flying around your base that build the structure for you. But right now, the player has to do everything by him-/herself and build on the foundation for the building to appear.

I have currently implemented two types of buildings. Oil pumps are for resource gathering and can only be placed on oil holes. Bomber Factories are for training/building infantry that will follow you to battle. Factories can be placed anywhere on the ground if there is enough room.

GIF
GIF

Training NPCs

Interacting with (clicking ‘E’ on) the built Bomber Factory opens a view where you can train NPCs (Non-Playable Characters). Eventually, there will be a separate building for each NPC you can train yourself. Also, training each NPC will take resources.

GIF

Due to a bug, currently, all the NPCs that you train spawn inside of each other.

NPC Movement

NPC movement was my biggest concern regarding this game. For the NPC to find a path from point A to point B there would be multiple ways. First is just moving the NPC there straight. That works well on an empty field, but what if there is an obstacle in the way?

Well, in Unity there are rays that you can draw to detect if there is something in the way. But if you detect an obstacle, you don’t really know how wide or high it is to decide how to get over or around it. That would result in many more rays for the player to decide how to get from A to B. And imagine an army of 50 NPC’s heading for battle, every one of them casting more than 10 rays. That is way too much for an average PC. This solution just doesn’t work.

So I remembered Unity also had something called NavMeshes. A pre-calculated system, that saves places where NPCs can walk. Perfect, right? No, because it is pre-calculated. The first time you place down a building, any NPC can get stuck behind it and it breaks the game.

Luckily for me, it turned out that Unity just recently released a runtime generatable NavMeshes. That means you can regenerate the NavMesh any time during the game. In fact, it is so new that it wasn’t even built into the game engine yet. I had to get it from Github. Implementing that into my game would have been ideal, so I did. And it worked like a charm.

Placing a foundation makes the game recalculate the walkable areas (light blue)

GIF

It was such an incredible relief to me and it works like magic, just like I wanted.

Played around with pathfinding, making an NPC follow me…

GIF

NPC Commanding

Right after NPC path-finding, NPC commanding was and still is a hard nut to crack. Many games have tried commanding NPCs into battle in the first-person view and as far as I know, it has always turned out clunky. It is a big part of my game and it will have to be perfect.

But for now, for starters, I decided to go with the basics. Make certain NPC active or listen and then give them a command. I created a quick selection view for four commands Attack, Retreat, Follow and Stay. From all four commands, only Follow and Stay currently work. That is because there is no sense of home-base or enemy built into the game yet.

Selecting individual NPCs requires you to go near that NPC and click ‘E’. Selected NPC is marked with an exclamation mark on its head. Pressing ‘Q’ on that NPC deselects it. Holding Tab, Ctrl or Alt brings up commanding view for all selected NPCs. I also built a shortcut for selecting (Alt+E) and deselecting (Alt+Q) all NPCs.

GIF

Networking

Working on so many new things in the game, I must admit some of them do not sync correctly over the network yet. I have yet to make the building multiplayer. Currently, when you place down a building in the game, you can see it, but other players in the match can’t. Same goes for NPCs – different players see them differently in the game.

There are possibly many more networking errors that I am not aware of and will have to attend to. I just decided not to postpone this development update any further because of these errors.

Try the Game

Even tho the multiplayer is currently broken, here is a download link to the current game. You can still try the new features in single player and look around the map.

Just a quick note: Last time I gave a download link it constantly got broken. My site might have thought it was a security threat and kept removing it. So if you can’t download the game, let me know.

Update Video

As the tradition goes, for every update, there is an update video. Like before I put together a little something for you to get a better feeling of how far the game has come. Enjoy!

This update had many more features than what I had planned before. But I wanted to introduce the map and the RTS aspect of the game together. As a result, it just grew and grew. 🙂 My next objective for sure is to get the networking side of the game fixed. Then maybe already start implementing resource management to the game? I’m not entirely sure yet, I guess you’ll see in the next update.

I hope you enjoyed!