- Home /
What should the best practice be to teleport player on top-down game
Hello everyone.
I've been developing software for quite some time already but I'm just starting with Unity.
To help me get started and learn to use Unity, I'm developing a prototype for a PC top-down game in which my player is walking around in a city block and he can enter buildings, which may have several floors. I though of 3 ways of doing this and was wondering what the veterans here have to say about it. Of course, please feel free to suggest other solutions.
1) Have the buildings and floors on the same scene, away from the action so that they cannot be seen, and move the player and camera accordingly. When a player enters a door (which would have a trigger), I would transport the player to the ground floor and move the camera too. When the player moves up or down the building I would keep moving according. The pros would be that all the assets would be loaded already, removing any loading. The cons would be that the assets would be loaded already (which uses more memory).
2) Have several layers (one for the city, one for the ground floor, one for the first floor, etc.) and show and hide layers. BTW I haven't managed to hide and show them programmaticaly yet, so I'm not sure if this would be a huge no-no from the start. Pros and cons would be the same as for option 1.
3) Use and load scenes. Pros would be memory usage, cons would be the possibility of having small load hiccups, which I would very much prefer not to have, of course.
Thank you all very much in advance for any light you may cast into this matter.
Answer by rutter · Jan 18, 2014 at 01:40 AM
Short answer: I'd recommend option 1 to start with.
Reasoning:
You mentioned you're developing for PC. It is possible to run out of memory, but ultimately that's going to come down to the complexity of your assets and scripts. Render time is a more likely concern, in my experience.
Option 1 takes advantage of frustum culling: anything outside of the camera's view area just won't be rendered. It's simple, automatic, and cheap (in terms of effort and runtime).
Option 1 may be able to transition to options 2 or 3, if it turns out you'd like to switch later in development.
Option 2 sounds like a nightmare for level design; I would not want to edit a bunch of objects that are all tightly packed and stacked together. This might be mitigated if you build them separately and use a script to stack them later.
Option 2 may suffer severe overdraw if you don't take careful advantage of layer and occlusion culling. Layer culling avoids drawing objects on certain layers; it's a camera setting, but it relies on properly configuring every object in the scene. Occlusion culling avoids drawing objects which are "hidden" behind other objects, but it's pro-only, and requires some advanced setup in your build process.
Option 3 requires programming time and may have loading hiccups, like you mentioned. If anything, I'd be more inclined to break things down by city blocks, tens of floors, or other large "sectors"? Depending on how complex each area is. Unless you have pro, level loads are blocking operations.
Thanks, Rutter. That's some nice chunks of precious information right there.
Excellent points. I believe Pokemon does it this way too. Think I read this somewhere but can't find it. Could be completely wrong though.
Your answer
![](https://koobas.hobune.stream/wayback/20220613130729im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Top-Down 3D-Like effect 2 Answers
How can I make my Enemy look/flip towards my player (2D TOP-DOWN) 1 Answer
Select 2D Object By Mouse ? 4 Answers
Sliding along walls in top-down 2D with no diagonal movement 1 Answer
2D Reflection Ripple effect 0 Answers