(WIP) The Expanse: Space Building / Survival Game

So, Theres one game I’ve been wanting to make for a long time. Its a space building game.
You know those games on facebook, like Clash of Clans or whatever its called, where you get some land, build some buildings, train some military and attack everyone else? Similar but better, more awesome, and in space.

I have been working over the mechanics of it in my head, and on paper for a while now, and have just started putting it together into unity.

This is basically my build journal. I’ll post demos as I progress, possibly screenshots, thoughts, etc.

Current Status
Version: 0.00001A Code Name: Just Getting Started.
Old Link: http://gamebucket.io/game/1bd1fa8b-aef2-4ca8-9fc8-1b9ecccf1be2
Current Version: http://gamebucket.io/game/f2d2ea82-93e7-483b-9a42-bb2944344f4b
See this post for current update: (WIP) The Expanse: Space Building / Survival Game
Here is what I have so far.
It’s not much.
Basically, when you load it, the game randomly generates and places 10 asteroids around a rather large playing field.
You can control the ship using WASD or the Arrow Keys.
All you can do right now is fly around the play area, and click on asteroids. When you click on the asteroid, it will show you in the top corner the size, its main resource and amount, and its secondary resource and amount.
That’s it for now.

Note I am just using free asteroid prefabs from the asset store, and the ship sprite from the laser defender section. Graphics are the least of my concerns right now. Once I have more of the actual gameplay mechanics down, then I’ll worry about creating/commissioning custom graphics for it.

Next Steps:
Mine Asteroids.
Each asteroid has two resources in it. Right now the possible resources are Ice (water), Metals, Crystals, Chemicals (fuel), and Other.
When the player clicks on an asteroid, a harvester drone will be dispatched (if one is available) and will start mining its resources.

Long Term Plans:
The player will start out with a very basic mother ship, and only one harvester.
The player will have to harvest resources in order to keep their mother ship running, to add on to it, to create more harvester drones, to create defenses (turrets, scout drones, patrol drones, etc) and so forth.

Player will be able to upgrade and research new technologies. Faster engines, More efficient refining machines for fuel, hydroponics, weapons, sensors, computers, fabricators. As he grows his mothership, he will be able to grow his population. Train people as laborers, mechanics, researchers, pilots, etc.

Space Pirates will be a problem the player will have to contend with. The player will also be able to branch out and explore other sectors.

Multiplayer Possibility.
The first itteration of the game will be single player, with AI controlling space pirates, and possibly other “players”.
Eventually, I would like this to be an online multiplayer game. Players could scout other players sectors, get attacked by other players defenses, or make alliances, trade resources or technologies, or even become pirates themselves.

I’ve got a long ways to go, but it feels good to get started.

Current Problem: Harvester Drone

When the player clicks on an asteroid, they will be given the option to dispatch a harvester drone to it.
When they do, a drone prefab needs to be instantiated.
The AI for the Harvester Drone needs to do the following:

  • Remember which Ship (in the event that the player has more than one ship in a sector) dispatched it.
  • Remember which Asteroid it was assigned to.
  • Move to the asteroid, and begin mining procedures.
  • Each asteroid has a fixed quantity of 2 types of resources, randomly determined at generation. As the drone mines, it can take on X amount of resources, as it does so the quantity of each resource is decremented accordingly.
  • Once the harvester drone has filled its cargo holds, it takes off from the asteroid, and takes the most direct route to its mother ship where it will unload its cargo for processing.
  • Once its cargo is unloaded, it needs to take the most direct route back to its asteroid to continue mining until the asteroid is depleted, or it is given other orders.
  • Each drone will have the following upgradeable variables: Flight speed (base drone is slow), Cargo Capacity, Mining Speed.

Things to consider:
Once the player has been playing for a little while, they will be able to create more harvester drones. So each asteroid will only be able to be harvested by a single drone, but eventually the player can harvest multiple asteroids at once.

Another development will be the drone and cargo ship combo. To start, the drone has to fly back and forth between its mother ship and the asteroid multiple times (depending on asteroid size and cargo capacity), and if the player is on the other side of the sector, that is a lot of wasted travel time and spent fuel. So the player can eventually build a cargo transport which will be able to park near the asteroid, dispatch its mining drone, and then the drone only has to go from the asteroid to the nearby cargo ship which has a much larger cargo capacity. Then once either the asteroid is depleted, or the cargo ship is full, it will return to the mother ship.

Potential complications for the player:
Space is a dangerous place. The player is going to have to deal with space pirates that want to steal his resources, such as a nice new harvester drone and its cargo. eventually, the player is going to have to contend with other players (be it AI, or human) that may not be overly friendly and may destroy the drone and its cargo.
While cargo ships and harvesters wont be equipped with weapons, its possible for the player to assign a fighter escort to its drones.

While I dont think the coding for this section will be too difficult, and I will be able to put a lot of what I learned in the Laser Defender section (Instantiating the drones, having one game object interact with another) I am going to have to look into pathfinding. I can’t use unities built in NavMesh capability due to the fact that everything on the playing field is dynamic. So I’ll have to implement the A* system or something similar.

Personally I think the movement should be a lot smoother, like your press forward and you start moving forward and then you come to a gradual stop, like in real space where you don’t have gravity or friction to slow you down.


Yeah, right now, I use transform for movement, just to get things working so I can work on the harder things.
Eventually, I’m going to use addforce for movement which will allow for more realistic movement such as use of fuel only when accelerating/decelerating and course corrections.

So I’ve got to to where a drone prefab instantiates any time I click on an asteroid.
Now I need to work on the movement script for the drone. So that it will go back and forth between the ship and the asteroid.
At first I’m just going to use Vector3.MoveTowards to make things work.

Things I need to start thinking about:
GUI: Right now when the user clicks on an asteroid, a drone is created, and the info about the asteroid shows up in the top corner of the screen. What should happen is there should be a HUD at all times, like in most games, a little radar screen in one corner, a scanner screen in the other that shows the info about the asteroid the user clicks on, then in the middle will be a menu screen. This is where the user could decide to harvest it, log it, etc.

Movement: For player movement, quit using Translate, and use AddForce to give a more realistic acceleration/deceleration curve.
For the drones, need to implement pathfinding, A* (which will also be used for enemies and other AI) just need to find a good A* class.

Just discovered I need to get yet another course on Udemy. Which one you ask? Why the Unity Physics course of course.

I want realistic, or semi-realistic gravity in my game. I’ve decided to change the setting somewhat.
Right now, its just an empty field with asteroids randomly placed in it. I’ve decided I want to make it a solar system, and to do that, I have to create a new physics engine for the game. Create a star, give it mass/gravity, put planets orbiting it, each with their own mass and gravity fields, then put an asteroid belt in there, maybe a couple and have them all orbit the main star.

Now I know there are systems in the asset store to do this. I’ve looked at a couple of them, and they would do the job nicely. But I am not going to go that route. They cost money I dont have, and most importantly, if I code it myself, I’ll have learned something very important.

Now I just have to wait till payday to purchase that course.

Harvesting Update.

Finally got drone harvesting to work.
When you click on an asteroid, a drone in instantiated, it moves to the asteroid you clicked on. “Harvests” some of its raw resources. Flies back to the ship and offloads them. It does this until the asteroid is completely mined. Once that happens, the drone gameobject destroys it self.

To Do:
Make the harvesting take time. Right now it’s instantaneous.

Implement intelligent pathfinding(A*) right now, it’s possible for another asteroid to get in the way of the drone and it doesn’t know how to handle that.

Soon I’ll have another playable demo up. Need to add some GUI stuff since anyone that tests it wont have access to the inspector to see things actually working.

Wow cool idea for a game man was wondering maybe you could have like an emergency call beacon the calls in the cavalry fighter ships when you get in trouble with pirate’s instead of a fighter escort then would save alot on programming AI maybe

Also any thought on upgrade able shielding, drill capacity, speed and or carrying capacity upgrade(s) for drones.
Ship Cargo Capacity would be cool for the freighter also. Maybe you can make multiple drone latch on to asteroids and drag it back to the freighter.

Just a few thought nothing really all that original of course but thing that are cool

Question for you why Unity over Unreal and reasoning?? Let me know when you need testing also i might be able to help with model’s some day.

Thanks Stomper

Thanks man.
It’s vaguely inspired by playing Star Ship Traders when I was younger.

That’s possible. The fighter escorts would mostly be for the drones that are out harvesting asteroids.
Eventually, the player’s ship, will have its own fighters it can deploy, not to mention its own weapons.

Eventually, just about everything will be upgradeable. Two of the most important resources the character will have are Researchers and Engineers. The player will start out with just a couple of each. More will have to be trained as the players population increases.
But in order to upgrade anything, the player will have to Research it, and this will take time, but will be sped up if they assign more than one researcher to the task.
Once something is researched, the player can build as many copies of it they want. Again, this will take time, and will be sped up if more engineers are assigned to it.

Ideally, every mechanic of the game will be upgradable. And there will not be an unreasonable limit to how far things can be upgraded. Just each time a particular system is researched/upgraded, it costs more and takes longer than the last time.

I had never considered letting the players drones move the asteroid. I’ll have to add that to my ever growing list.

Mainly, because I’ve been working on the Unity course. So its the one I know/am learning. Also, while I wont have an issue with purchasing the pro license if this becomes profitable for me, I dont want to have to worry about royalty payments. I know its not much, and I do intend on completing the Unreal course and potentially using their product in the future.

Thanks Stomper. It’ll be a while before I’m ready for testers, but I’ll let you know when I’m to that point.

Right now, I can just fly around and harvest asteroids. Need to work on a lot, user interface, research mechanics, etc. Also need to implement a save/load capability, as everything starts over each time you start the game right now.

Current Status
Version: 0.00002A Code Name: Pulling out of the drive way.

Up or W to accelerate
Down or S to Decelerate
Left/Right A/D: to rotate.
Ship will keep moving at speed unless you decelerate.
There is no reverse at this time. Will be adding it in next version.

Right click on asteroid to bring up action menu.

What’s changed:
The play field is bigger, and now 100 asteroids are being generated on start.
Added UI elements: Popup menu when right clicking on asteroid. Panel showing current resources.
Controls have changed. Instead of instantly moving/stopping when you hit the keys, you accelerate and decelerate.
Now right click to scan or harvest asteroid.
Destroy button does nothing at this time.

Minor update, demo coming soon.

Changed the graphics for the asteroids, player ship, and drone, using CC0 resources I found online, not sure if I will stick with them or eventually create my own or commission something from a talented artist.

Added a reverse functionality. Its limited in speed, to mimic using things like docking/attitude thrusters instead of the main drive system.

Fuel: Now, all acceleration, deceleration, turning, etc takes fuel. Once the ship is out of fuel, it can’t move or change its speed.

Fuel Production: The ship will now automatically make fuel, as long as you have sufficient quantities of the resources Ice and Chemicals

Out of Fuel Contingency: This is on my farther out to do list. Right now, harvester drones can only harvest asteroids the player physically clicks on and tells them to.
Since the player is either stuck unable to move, or coasting unable to stop or turn, it would be game breaking if they completely run out of fuel when they dont have enough Ice/Chemicals to create more.
To avoid this, there are a couple possibilities.
Emergency Reserves: Enough fuel in reserve to travel at a reduced speed until you can find the resources you need to make more fuel.
Fuel Depots: The player can create and place fuel depots around the sector, then when the player has an excess of resources needed for fuel production, the player can offload them to the fuel depots.
A possible upgrade to this would be fuel depots that wander the sector searching for asteroids with the proper resources and harvesting them.
Drone Dispatch: Have a special drone that the player can dispatch that will search out and harvest the required resources to make fuel.

Things on my more immediate to-do list:
More intelligent AI for the harvester drones. Right now, they just go directly to their target (asteroid/ship), and tend to bump into things, especially if the player moves or dispatches more than one drone.
At minimum, they need collision avoidance subroutines.

Cargo capacities. Right now you can harvest every asteroid the game generates and not run out of space. Need to implement a maximum cargo capacity, and cargo management functions. It will do the player no good to have a cargo hold full of Crystals and Metals if they run out of fuel. So the player needs to be able to dump some of their cargo at will. Possible upgrade, would be to dump them in storage containers that the ship could come back and pick up at a later time.

Saving/Loading. This is one of my top priorities right now. A game like this is no fun if you start over every time you play it. I need to implement a save/load capability. I’ve read a few tutorials on the matter, and it shouldn’t be that hard. For the PC version, I’ll just save everything as XML files. Though before the game is released I’ll need to some kind of encryption to them.
For the browser version, I need to write a REST interface in PHP so that anyone that wants to can play and save their progress in my various demos. The users info will be saved to a database.
Once this is done, this will be my first major update. I hope to have this in place by the end of the week, and have it available online for people to try out.

Then I’ll be able to focus on the fun stuff. Researching upgrades, building new ships, depots, etc. Maybe even put in some roving pirates to make it interesting.

1 Like

Really like the idea, keep it up :slight_smile:

Privacy & Terms