Hi Guys, I'm very new to coding with C#. I was building a game and would like to generate levels existing out of 6 different colors prefab (circles). The problem is I can't find a solution that's works for me... Anybody know how to do this? Thanks, Sam
Hi @SamVorst, First figure out the logic how you want to build your level, then think about how you would code the logic and create the required scene items etc. I have no idea how you would want to place your objects as your description really doesn't offer much details. But in general terms the procedural level generation might work like this: 1. Generate random value. 2. Instantiate the prefabs to the scene according to this random value. 3. When some threshold is crossed, repeat from 1. You might also need to remove objects from time to time, so that you don't get too many in the scene. Depends on your game etc. The setup you need might be very simple, or a bit more complex depending what you plan to do. If you for example just want to randomize some platforms in front of the player and you advance in your game to one direction, there's not much trouble there. You could just instantiate platforms at randomized distance within a range and offset them sideways. That would already keep on building randomized level. However you might need to consider moving the level so that it's close to the origin if your game would be such where the player can move long distances. This would be to avoid floating point number inaccuracies. But if your player moves just moderate distances in the scene, you don't need to worry about that. Levels that go here and there like some dungeon crawlers are much more complex to setup, but there's many tutorials and articles out there on the web. But it would be better if you start to build your level generator system and try figure out every problem at a time, then ask for more help.
hi that`s not a completed solution, but maybe you make customization in your game and that help you with your question Code (CSharp): using System.Collections; using UnityEngine; using UnityEngine.SceneManagement; public class GameLevel5 : MonoBehaviour { //load level manual from another level public void LoadSomeLevel() { SceneManager.LoadScene ("Scene 20"); } //your custom random level public void MyRandomLevel() { //your customization for random level } void Start() { //LoadSomeLevel(); MyRandomLevel() ; } }