Map Generation
The map in this game consists of platforms, which are randomly spawned. Multiple platforms then form a layer. At the current state there are 8 different platform types as well as a start platform and three boss platforms. Each platform is a prefab, consisting of:
- the platform model itself,
- static objects on the platform,
- moveable objects, which can be hooked,
- spawn-points for enemies,
- a NavMesh for the enemies,
- four small platforms around the main platform and
- a trash spawner.
The map generation starts with a for-loop. The for-loop is started and repeated depending on the number of layers (in the current state there are 3 layers). At the beginning of the loop, a random platform prefab is spawned. In the first layer the start platform is instantiated at an initial height. This first platform acts as the center platform of the layer. The layer is then generated around this center platform.
For the layer, a random number of platforms between a min and max value is chosen. A loop is then started, repeating until all platforms are spawned. This loop builds rings around the center platform. It first spawns a platform and positions this platform at the position of the center platform. Then the platform is moved for a defined distance in the forward direction of the center platform. The platform is then rotated around the center platform. The rotation angle is randomly increased after each platform. This way, the platforms form a ring around the center platform. A random offset is the added to each platform, in order to avoid a symmetrical map. If the rotation angle is bigger than 360, a new ring is started by increasing the defined distance to move the spawned platform in the forward direction of the center platform. The spawning of platforms is repeated until the number of before defined platforms is spawned and afterwards, a random boss platform is spawned. Then the layer is checked for overlapping platforms and overlapping platforms are then deleted.
The next step spawns transitions between the platforms. All platforms are stored in a 2D array, the first index describing the ring index and the second index describing the platform index. The closest platform in the next ring is located for each platform and random transitions are spawned between the platforms. The number of transition objects depends on the distance between the platforms.
Now a layer is complete and the transition to the next layer can be spawned. This transition is at first deactivated and only activates when the boss of the layer is defeated. For this transition, small platforms are spawned in a spiral pattern upwards, the number of platforms is again depending on the distance to the next layer.
The center platform of the next layer is then placed directly above the last platform of the last layer and the next layer is generated around this platform. The number of platforms is decreased per layer. This process can then be repeated for any number of platforms per layer and any number of layers. The system also contains a lot of min and max values, which can be tweaked, for different map designs. These values include position and rotation offsets of each platform, angle to rotate a platform around the center platform, distance between rings, distance between layers, ...
Get Project Grappling Fight
Project Grappling Fight
A physics-based 3D single player Rogue-Like/Jump’n’Run.
Status | In development |
Author | grappling_fight |
Genre | Action |
Tags | 3D, First-Person, Monsters, Physics, Roguelike, Singleplayer, Unity |
More posts
- 3 Steps to Better PerformanceJun 01, 2022
Leave a comment
Log in with itch.io to leave a comment.