In many games, like Meep City and Adopt Me, you own a house that is located in a neighborhood with other houses. I am wondering what techniques are used to implement such a housing system.
Is this all done on a single server and place? Or are multiple servers and places involved?
How do you implement a player going from the main game area into their neighborhood?
How do you implement a player going from the house exterior into the house interior? (The exterior is often just a facade, and the interior is usually a separate space.)
Their House is stored and loaded once they join, checking if place has availability if none has, a new place will be created and the player will be sent there.
The game contains place that can communicate with each other and store these information.
Imo the method for me would depend on the maximum amount of players per server, but I would and have previously just programatically generated the plots dependent on the number of players in the server as they join in a predefined location.
Once you have a plot the rest is just instancing houses and its interior from your DataStore. The difficulty comes when you have a game like Bloxburg in which you need to store the position/orientation/colour and other modifiers as well as the object to instance as you would need to compress your data to be within the DataStore limit.
Thus:
When a player joins check if there is an available plot
If available: set plot to unavailable and claim for the new player
If not: instantiate a new plot based on your parameters and claim for the new player
Send a GET request to your DataStore to determine the house and any contents that need to be placed in the plot
Store any changes to said house/its contents
Repeat for every player / every time this player returns
I am scripting a game that uses a similar system. I don’t really understand your question but I’m gonna explain how it works. So what they do is parent all the other areas to replicated storage on the client in a local script that should not be loaded, and whenever the player enters a new area they get the area from replicated storage that should be loaded and remove the other area. Let me show you an example below of how this would work:
local areaModels = workspace.AreaModels -- this could be a folder or model that contains all areas of the map
local starterArea = areaModels:WaitForChild("StarterArea") -- this is the location where players will be spawned in meep city for example all players are spawned on the playground
--the next step would be to parent all the worlds that should not be loaded to replicated storage. I would recommend having a folder in replicated storage to accomplish such task
local hiddenAreas = game.ReplicatedStorage:WaitForChild("HiddenAreas")--a folder in replicated storage to hold all the worlds that should not be in the workspace
-- ok so now you would have to remove all the other areas that should not be loaded on the client
for _,area in pairs(areaModels:GetChildren())do
if area ~= starterArea then
area.Parent = hiddenAreas
end
end
--tip:remember that because of filtering enabled any thing done on the client will not replicated to the server and other clients so when we hide the areas on the client it will only happen on the client
ok so the next step would be how your going to load in and out the other areas. In meep city and adopt me the other area is loaded either when the player walks through a door or through one of the portal things. So what your gonna have to do is detect every time a player touches or walks up to one of those areas. The most efficient way to do this would be by having a folder in each area model that stores all the doors and portal things and all of them should be models that have a primary part set and that primary part would be the area that the player should touch.
After you have done this you have to now handle hiding other characters which are not in the same area. Personally, I have one module script that has a table with all the doors and portal names along with their respective location names. After, you would have to store this location and update it every-time the player enters a new area. In my game what I do is detect the touching of the door sensor and portal things on the server and then I get the respective location from the list of location modules and updates the players location data in a table on the server that stores all the clients locations. After I have a remote event that fires every time a player location changes and It sends over a table of all the other players which are in the same area as them, and then on the client when the remote event is fired it parents all other character models to a folder in replicated storage.
That’s how it is done. I know for a fact that they do not use different servers to accomplish this because of how quickly you move in between the different areas. This is not a easy system to implement but once made it is very efficient because It will make the game faster on mobile because it reduces the number of parts that are in the workspace. This system took me about a month to make and it runs very well. I hope this response provides you with a good starting point.
oh i see you formatted question well here are the suggested implementations:
question 1 answer:
It is all done in one place and no private servers are used question 2 answer:
this was answered in my previous reply question 3 answer:
so you need to first create the template for the houses. In adopt me and meep city each house has a fixed exterior layout and a fixed interior layout which can then be customized. So what you could do for the neighborhood is have one large area and then put invisible parts on the floor where houses can be spawned. After you can have a table that stores a list of all invisible parts that have a house on it . Then when the player joins you would put the exterior of the house on the invisible part not being used and parent it to the neighborhood model. After for each house model you would have another model inside replicated with the inside of the house. After when the player enters the house you would get the house from replicated storage and parent it to the workspace on the client and parent the neighborhood back to replicated storage.