Skip to content

First Pass at End Game

Today I started working on getting the end game loop hammered out a little. I mainly wanted to focus on getting a game over screen when the caravan reaches the end of the final path.

In order to actually reach the final path, I needed to make some changes to the Game Manager class to stop spawning tiles after a certain number of them. Instead of just endlessly spawning tiles, I added a configurable limit to them and changed it to where the first and last tiles are always an Outpost with the ones in between pulling from a pool of forest tiles (even though we currently only have one forest tile).

Unity inspector showing new level config

I reworked the whole system to load whatever the next tile should be and made it more configurable. In addition to the number of Tiles to keep loaded, now we can set the total desired number of Tiles and how many Tiles should be loaded initially.

Now that we have a final Tile being loaded we can determine when the Caravan has reached the end of the line. When the Caravan gets to the end of the final path, we fire off an event that starts the end game process. After a configurable delay, the game moves to the End Game scene, where the Player can either restart or exit the game.

Placeholder

It is set up to show Game Over for when we get to doing the Player death. It is configurable on which one to display by default. More logic will need to be added to dynamically change the state when it is loaded.

Placeholder

When the Player restarts, it will display a loading screen while the main game scene is being loaded. This will become more important once we start getting more assets into the scene.

Placeholder

Here is it all in action.

Placeholder

Caravan Crew Management

After getting the basic end screen added in, I started working on getting the crew being spawned in.

Andrew did a good job of getting the basic crew prefab made up with a few animations, so I was able to drop that in, almost as is! The two things I needed to add were:

  1. A CaravanCrew script for controlling the individual crew members
  2. The material for the crew so they aren't just white

I also added an overall Caravan Crew Manager that is responsible for actually spawning the crew into the level. The idea for the crew spawning positions is that each sled has a number of points around them that the crew will be spawned on, and eventually use those points as "tethers" when they follow the caravan.

Placeholder

Because we can have a variable number of sleds in our caravan, we want to make sure that each point has an equal chance of being picked. To accomplish this, I added all of the points from each sled into a singular list, then pick a random point from the list. I also wanted to ensure that multiple crew aren't stacked up on the same point (unless there are more crew than points). To account for this, whenever we pull a random point from the list, we remove it from the original list and add it to a "used" points list. Then, when there are no more points in the original list, we reset the used points list back to be the original points list. This will prevent multiple crew on the same point until we have exhausted all of the points.

You can see the spawning in action below. We have two sleds and three crew. Two crew got assigned to points on the second sled, while only one got assigned to the first sled.

Placeholder

While I don't have the crew actually following the caravan, I did start working on getting a NavMesh working with our dynamically spawned environment tiles. I found this tutorial by LLamAcademy that had a similar setup to what we are doing. While most of the video doesn't apply to us, it was still helpful. I am still working through that video but got it (mostly) working as expected. When I generate a new tile, the NavMesh is extending to the new tile but it is still including the last removed tile. If you move far enough along where multiple tiles have been removed, it does remove the ones older than that last removed tile (i.e. there is always one "ghost" tile).

Placeholder

I think this has to do with how destroying game objects in Unity works. While we call the Destroy method before regenerating the NavMesh, I think it is still being included because it hasn't been cleaned up by Unity's system, since it is still the same frame. This is all just a guess and will need more investigation on.

Icons

Andrew has been passively working on the designs of various icons. I threw some ideas at him, based on the direction he was going with them, mainly the Warm and Hypothermia icons. For the Warmth mechanic, eventually we will need three icons: Warm, Hypothermic, and Freezing.

Placeholder

There was quite a few ideas that were thrown out but (at least for the Warm icon) we settled on some type of fire surrounding a thermometer.

Placeholder

Teaching and Learning

Andrew is still learning Unity and C# in general. I spent some time answering his questions with some examples. We also got the chance to do some pair-debugging to figure out why his player suddenly stopped accepting input. It wouldn't move or look around. Luckily, this turned out to be an issue with some left over code he had added at some point. Once we got that cleared up it was back to working as expected.