Search Unity

Entering Structures, Best Approach?

Discussion in 'World Building' started by TheNerdSherpa, Jan 4, 2019.

  1. TheNerdSherpa

    TheNerdSherpa

    Joined:
    Dec 11, 2018
    Posts:
    45
    Question 1:
    I have several buildings on my map that I would like to create an interior for. I want the player to go to the building and left-click the door to enter, which would load them into the interior of that building. Here's the approach that I'm thinking for that action:
    1. Create the door as a separate object from the building
    2. Use a raycast to say "is the player within 1.5 meters of the door?" (if true, prompt text "Enter Building?")
    3. If the player, using the action button "e", clicks the door; a load screen will come up and the interior will load
    (note: Have a pre-staged 3rd-person controller in the interior?... I mean, Unity isn't going to somehow teleport my controller from my main map to the interior for me, right?)

    Am I on the right track here?

    Question 2:
    Where should I stage all of my interiors?
    1. As separate scenes?
    2. In the same scene, somewhere way off the map so they wont be pulled into memory until the load script is for that interior is initiated?
    3. In the same scene, but on a separate layer and make them invisible to the 1st layer?

    Whats the most optimal way to approach this?
     
  2. TheNerdSherpa

    TheNerdSherpa

    Joined:
    Dec 11, 2018
    Posts:
    45
    If you know of any tutorials for this, please post a link.
     
  3. olix4242

    olix4242

    Joined:
    Jul 21, 2013
    Posts:
    1,260
    I think that you should use separate scenes. But this really depends how complex your interiours are and how complex your city is. Main reason for doing thisis how lighting works - interiours require different lighting techniques and different baking settings. HAving all separated into scenes simplifies workflow and adds to a performance.
     
  4. TheNerdSherpa

    TheNerdSherpa

    Joined:
    Dec 11, 2018
    Posts:
    45
    I'm thinking that using separate scenes is the best approach for me. That is, until I get into asset streaming. I'm new to all of this, and that seems very complicated.

    Thanks for your advice on this! Now I'm off to figure out how to trigger a "new scene" load....
     
  5. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    210
    This might help you out:

    Its the basis for how I'm using Some of the Building from CityScape.
    Just cut a holw for a door, and when you enter a range form the door it loads the interior and when my doors close [ei My script closes it behide me it unloads that building interior]... you can have a building with larger interior than the exterior doing it this way with carefully crafted loading zones
     
  6. TheNerdSherpa

    TheNerdSherpa

    Joined:
    Dec 11, 2018
    Posts:
    45
    [QUOTE="Just cut a holw for a door, and when you enter a range form the door it loads the interior and when my doors close [ei My script closes it behide me it unloads that building interior]... you can have a building with larger interior than the exterior doing it this way with carefully crafted loading zones[/QUOTE]

    That's Great! Thanks Paul
    Questions:
    Do you dump the exterior while you're in the building, or do you load the interior additively?

    If you dump the exterior, do you have a trigger collider on the inside to load the exterior as you are leaving?
     
  7. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    210
    I only dump other if there no chance of immediately leaving again. Otherwise I just leave it loaded. For example if I enter a subway, I designed them so I have to turn a corner. I have a load gate at either side of that corner so I can tell if the player intends to enter or leave. In that case I dump it, but if it's just a small building like a 1 FL depth store I leave it loaded since they won't be in it for very long...make sense?
     
  8. TheNerdSherpa

    TheNerdSherpa

    Joined:
    Dec 11, 2018
    Posts:
    45
    Yes it does, thanks.
    I was worried about how to handle situations where the player might turn around before they hit the dump gate, leaving both scenes loaded.

    Here's an example of the setup that I'm thinking about:
    Each [ __ ] is a trigger-collider

    ***SceneA*** [dump=B][load=B] ________hallway________ [load=A][dump=A] ***SceneB***

    The player can go in either direction and the same mechanics should work. Even if the player decided to turn around in the middle, the dumps on each end should remove the loaded scene.

    Replace "hallway" with long valley between large terrains; or door between rooms; or elevator... etc.

    This is a great new tool for building what would seem like an open world, the player would be unaware of the loads.
    Thanks for doing the research on this!
     
  9. Regen_erate

    Regen_erate

    Joined:
    Dec 12, 2018
    Posts:
    16
    Try maybe using modeling software like Blender or the like.