Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Rendering models within a radius of the user efficiently?

Asked by 3 years ago

A few people and myself are organizing another year of a community-based event that’s been going around since the early 2010s. Users submit stalls with their creations and they’re displayed in a purpose-built venue for the occasion for a few days before we close shop and prepare for the next year. This year, we got double the amount of submissions that we would’ve normally gotten as we started branching out into other parts of the wider community instead of a small sub-section. This has however, brought up problems with experience optimization especially with such a high number of submissions and varying levels of part counts and model sizes.

We set limits on the stalls such as width, length and height, as well as part limits (the maximum for this year was 1000 parts). Of course we can’t load all of the stalls all at once or that would mean hardly anybody would be able to visit let alone go around the venue as smoothly as possible. We use a radius-based method with the user's HumanoidRootPart and a stall PrimaryPart, in math.abs and Magnitude. If this was smaller than the radius value set then the stall would be loaded in for the client:

local frequency=1.5 while wait(frequency) do for _,stall in pairs(stalls) do if math.abs((character.HumanoidRootPart.Position-stall.PrimaryPart.Position).Magnitude)<script.maxd.Value then stall.Parent=WorkspaceStalls else stall.Parent=ReplicatedStalls end end end

However this year we seem to be having significant issues with how people are able to play the experience. We’ve tried two methods to load stalls from the server to the client, however both have had issues that we’ve been unable to resolve.

The first method was to fetch the stall model from server storage, place them in a folder on the client and then proceed to place them in the workspace. This method would make unions and other assets load faster, however we discovered in testing that it would cause massive memory leaks on the server side causing crashes after a few minutes with about 10 players (not a great outcome for an event where hundreds are expected).

The second method instead moved the stalls folder from ServerStorage to ReplicatedStorage (not a great idea as it exposes all the stalls to the client which can make leaking much easier for bad actors), and follow a similar method to the first method. While this would prevent the memory leaks, stalls would take much longer to load for the user, or sometimes just not load at all on the client-end. This method is also susceptible to temporary short-lived lag spikes when moving between locations (halls). However with both methods, we could not establish a stable ping on either the Client or Server, both would have pings in the hundreds (or sometimes thousands) which is not ideal.

Why not use StreamingEnabled? We’ve tried, and that’s resulted in elements breaking along with part of our GUI elements (mainly the main menu) meaning nobody is able to play, or takes significantly longer for anything to actually happen. StreamingEnabled also broke tests in studio, as it would only present us with a blank skybox and proceed to do nothing afterwards.

TLDR Is there any method to efficiently load/unload stalls from the server to the client that doesn’t cause any significant performance hit to the client, or cause the server to go into meltdown and crash without using StreamingEnabled?

0
Hmmm.. Why not create another instance of the game? Let players teleport to another game xXLegendGamerz16Xx 231 — 3y
0
We have this in place already for stalls that don't fit in the existing place as well as other categories. It exhibits the same problems as the first place does. CondescendingReality 7 — 3y

Answer this question