Hello Unity fans and welcome back to the series. After the last few videos, recursion now allows us to find the least amount of groundwork required to place a building in a particular spot on the map, and we have an automated task system to manage builder actions. So, we can now instruct our builders to actually perform that groundwork and then construct the required buildings. We would like this construction to happen progressively to fit in with the real-time nature of the game. Let’s see how we can accomplish this.
The Creative Modeller: • Introduction to model railroad tutorials, ...
Part0 (Introduction): • [Unity3D Hex Map Game Dev] 0: Introduction...
Part1 (Hexes to Water): • [Unity3D Hex Map Game Dev] 1: Hexes to Water
Part2 (Features and Textures): • [Unity3D Hex Map Game Dev] 2: Features, Te...
Part3 (Units, Visibility): • [Unity3D Hex Map Game Dev] 3: Units, Pathf...
Part4 (Random Maps): • [Unity3D Hex Map Game Dev] 4: Creating Ran...
Part5 (Post Processing): • [Unity3D Hex Map Game Dev] 5: Post Process...
Part6 (Resource Gathering): • [Unity3D Hex Map Game Dev] 6: Automated Re...
Part7 (Spinning Selector): • [Unity3D Hex Map Game Dev] 7: Spinning Obj...
Part8 (Preparing for Resources): • [Unity3D Hex Map Game Dev] 8: Preparing fo...
Part9(How Much Wood?): • [Unity3D Hex Map Game Dev] 9: How Much Woo...
Part10(Dynamic Trees): • [Unity3D Hex Map Game Dev] 10: Dynamic Trees
Part11(Meet The Meeples): • [Unity3D Hex Map Game Dev] 11: Meet The Me...
Part12(Harvesting Wood): • [Unity3D Hex Map Game Dev] 12: Harvesting ...
Part13(Harvesting Stone): • [Unity3D Hex Map Game Dev] 13: Harvesting ...
Part14(Walking Around Wallls): • [Unity3D Hex Map Game Dev] 14: Stop Walkin...
Part15(Multiple Unit Types): • [Unity3D Hex Map Game Dev] 15: Preparing f...
Part16(Manipulate Terrain): • [Unity3D Hex Map Game Dev] 16: Manipulate ...
Part17(ResourceBuilding Upgrades): • [Unity3D Hex Map Game Dev] 17: Resource Bu...
Part18(Camera Fly-through): • [Unity3D Hex Map Game Dev] 18: Camera Fly ...
Part19(Animated UI): • [Unity3D Hex Map Game Dev] 19: Animated Us...
Part20(Automated Farming): • [Unity3D Hex Map Game Dev] 20: Automated R...
Part21(UI Anchors, Buttons, ToolTip): • [Unity3D Hex Map Game Dev] 21: UI Anchors,...
Part22(Linking Graphics, Mechanics, UI): • [Unity3D Hex Map Game Dev] 22: Linking Gra...
Part23(Segmenting Hexes): • [Unity3D Hex Map Game Dev] 23: Segmenting ...
Part24(Smooth Irregular Movement): • [Unity3D Hex Map Game Dev] 24: Smooth Irre...
Part25(Pathfinding on Segments): • [Unity3D Hex Map Game Dev] 25: A* (A-Star)...
Part26(Avoiding Unit Collisions): • [Unity3D Hex Map Game Dev] 26: Avoiding Un...
Part27(Inverse Movement): • [Unity3D Hex Map Game Dev] 27: Inverse Mov...
Part28(New Textures): • [Unity3D Hex Map Game Dev] 28: New Versati...
Part29(Assigning Workers): • [Unity3D Hex Map Game Dev] 29: Assign Rand...
Part30(Tasks Fly-through): • [Unity3D Hex Map Game Dev] 30: Automated T...
Part31(Progressive Building Preview): • [Unity3D Hex Map Game Dev] 31: Progressive...
Part32(Automated Task Queues): • [Unity3D Hex Map Game Dev] 32: Automated T...
Part33(Optimal Placement Recursion): • [Unity3D Hex Map Game Dev] 33: Find Optima...
After determining the optimal groundwork configuration, we have a list containing references to a number of cells, specifying how many elevations each needs to be adjusted by, as well as whether the small randomness built into the height needs to be cancelled. You’ll recall that we’ve added some randomness within the same elevation level to keep patches of ground from being absolutely flat. However, when a single building should overlap more than one hex, those hexes need to be forced to the exact same level, ignoring the randomness. So, we add one digging task on the centre segment to our task queue if the randomness needs to be cancelled out, and three digging tasks for each level that the hex needs to be raised or lowered by. We’ve limited this to 1 level for now, but could easily handle two levels. This means that buildings will be constructed faster on flatter land, while very uneven land may require more groundwork, taking more time to complete.
In order to let the change in elevation occur gradually while the digging is taking place, we determine how many digging actions will be required in total on each hex. Then, the digging animation triggers an event at a specific point in the animation, at which we play a sound. A group of digging cycles forms one digging action, at which point we create some dust, which will be destroyed after a few seconds, and adjust the elevation of the hex slightly. This step just calculates by how much the y-position needs to be adjusted and updates the cell’s coordinates.
Here you can see how the task queue handles these actions. If you want more detail on this, check out the video link in the top-right. What’s important for this video is the Flatten Hex method. It merely adjusts the elevation slightly each time a digging action completed and checks whether the hex has now been completely flattened. Note that we also need to change the y-position of each unit on the hex, to prevent them from floating or disappearing into the ground. Once the hex has been flattened completely, the build tasks need to be activated. We’d like to keep other units off of the building site, so we add a large movement cost to it. You may have also noted how we change the texture of the digging and building sites to a dark brown temporarily.
Информация по комментариям в разработке