Make a new level! - smkmth/RPG2 GitHub Wiki

My level manager might seem a little unintuitive at first - it builds the level using data from a scriptable object instead of having all the elements in the scene already in place - which means there are a couple more steps required to build a new level.

i am doing this for a reason - because each level is populated by a script, i can dynamically change what items show up there, what people show up there, where the player appears ect ect.

however - i am not like expert coder or whatever, so i might have made things over complicated or whatever, still learning. i wrote this guide for making a new level for myself if i forget how it works later on, or i am banging my head trying to work out why somthing dosnt work now ect.

  1. make a new scene
  2. Add scene to build order
  3. make a new level data scriptable object
  4. fill in who is in the scene and where they are on the level data object.
  5. Give the level data object a name, somthing distinctive.
  6. make sure to fill in the player entrance - thats where the player will spawn.
  7. inside the _app object is a child called manager. navigate to that in the inspector
  8. on this manager object is a component called levelhandler.
  9. this component has a list called levels. put the leveldata scriptable object inside that list.

your done, a level will now exist and be in the game. setting up a hook to navigate to that level is also somewhat easy. here is an example - to demonstrate where all the code goes and stuff.

  1. make an object in the level - somewhere approprate as an exit portal - like a door or somthing.
  2. (optional) Add a marker on the ground infront of the object, so the player dosnt just walk halfway into it while interacting.
  3. add the component 'Interactable'.
  4. drag the marker you made to the interactable marker field.
  5. add the component 'Area Exit'
  6. fill in the two fields - one with a string saying what scene you want this exit to lead to
  7. the other should say what leveldata you want to load.
  8. SPELL CAREFULLY - its litearally searching through the built scenes and level datas for the correct thing to load

A few notes

  • at the moment each level data has only one playerEntrance - which means multiple leveldata files need to be used if you want the player to appear at a different door. might change it later but seems fine for now.