Private void SetSpawnPosition(DungeonGeneratorLevelGrid2D level) / Move the player to the spawn point of the level. We place the player prefab directly into the scene and implement a simple post-processing logic that finds the spawn position marker and moves the player there after the level is generated. Instead of placing the player prefab inside the room template, we simply create an empty GameObject that will act as a marker of the spawn position. However, there is also a different approach to achieve the same result. In Example 1, we placed the player prefab directly in the Spawn room template to make sure that the player always starts in the correct room. LevelDescription.AddCorridorConnection(connection, corridorRoom, ()) Var corridorRoom = ScriptableObject.CreateInstance() ĬorridorRoom.Type = MetroidvaniaRoomType.Corridor Go through individual connections and for each connection create a corridor roomįoreach (var connection in ()) LevelDescription.AddRoom(room, RoomTemplates.GetRoomTemplates(room).ToList()) Room templates are resolved based on their typeįoreach (var room in ()) Go through individual rooms and add each room to the level description Var levelDescription = new LevelDescriptionGrid2D() Protected override LevelDescriptionGrid2D GetLevelDescription() / It prepares the description of the level for the procedural generator. / This is the main method of the input setup. Public MetroidvaniaRoomTemplatesConfig RoomTemplates Public class MetroidvaniaInputSetupTask : DungeonGeneratorInputBaseGrid2D The implementation will go through individual rooms in the level graph and based on their type it will assign corresponding room templates.įirst, we create the mapping between the type of the room and the available room templates: Instead, we create a custom input task that takes a level graph as an input, together with the mapping between the type of room and the available room templates. We create a level graph as we would normally do, but we do not assign any room templates to it. We decided to use a custom input setup to prepare our inputs. It currently looks exactly like the default implementation, but we use it just in case we need some additional functionality later. Use the type of the room as its display name. We do not need any room templates here because they are resolved based on the type of the room. This approach is very similar to what we do in our algorithm. Their procedural generator is then guided by the graph of rooms and picks a random room template for each room. Both the room templates and the graph are usually different for each stage of the game. The main idea is that they have hand-made room templates and a graph that describes the structure of the level. An article about their approach can be found here and a video here. They use procedural generation techniques to generate levels of the game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |