I’m working on a 2D game kinda like Project Zomboid
I’m using a top-down view with the “Horror City - Tile Pack” from itch.io which looks like
I’ll also add zombies which can follow and attack you.
What i’m trying to do is to be able to go inside buldings (inside the same scene, not using another one) and to have multiple floors.
From the outside, the buildings should look like on the picture above, but when you enter the buildings, you see the 1st floor and the walls are mostly hidden. When you go on the 2nd floor, you see the 2nd floor but not the 1st one etc …
I found another trade discussinf about it here Project TaO - #8 by Ivanskodje , but i’m kinda sure that using this approch (based on what camera can view or not), i won’t be able to make zombies follow you if you change floor since zombies won’t “understand” the concept of floors, and i don’t want players to be able to dodge zombies by going up and down the stairs making zombies desaggro them.
Any one have any tip or idea in how to andle that, i’ve been looking over internet but there is almost none discussions avout floors in 2D unities with tilesets.
No problem!
Attach an isTrigger collider to the doors of the buildings you want to enter.
Set up the “inside of building” in the same scene. You only need to create an EmptyGameObject for the player to warp to. So let’s say you want a panel to pop up when you go inside the isTrigger collider, right? The UI panel contain 2 buttons and text: “Would you like to enter?” button1 = yes, button2=no
If yes, then use your player’s transform.position and set it to equal that of the empty game objects transform.position. You can use an IEnumerator to make the transition seem a bit smoother rather than instantly warping.
Player walks into door collider
UI panel pops up
Player chooses either yes or no
If yes, warp to the “inside”; no, then panel closes.
So if you create a Teleport script, you attach it to each door. You’ll need 2 public Transform variables: Outside door and Inside door. That way to can warp back when you’re ready to go back outside. Then attach the script to you doors and drag where you want to go from each door into the field within the inspector.
If this seems confusing to you, I can provide you with a code example.
actually, i don’t really want the player to “teleport” but i want the player to be able to open the door and then walk freely inside and outside of the building without teleporting. So Zombies would be able to walk too inside and outside a building if the door is still open. But that’s not really a problem, i can make a trigger close to the door and, as you mentionned, have an UI button for player to click to open/close the door (and by the same time, activate/desactivate, the collider so player can move in)
My issue is actually in the visual aspect. I want the player to not be able to see what’s inside of the building if he’s outside (like in the picture from my previous post), but be able to see what’s in the building as soon as he walks in, something like the next picture from Project Zomboid
Plus, i’'ve no idea, yet, how to handle multiple floors in 2D and allow zombies to follow you even if you change floor, kinda feel like i’ll have to go 3D …