Solved
- The (non-BasePart) descendants of a BasePart are guaranteed to be streamed in with the BasePart though not immediately (i.e. after added events related to the BasePart)
- Because the descendants aren’t all added at the same time, CPU spikes generally won’t be a problem, unless there are a large amount
- Read solution for more details
Hello DevForum!
I am creating a game with streaming enabled, where collections of Instances form “machines” that players can interact with.
There is a lot here, if you’re very knowledgeable about streaming enabled please feel free to scroll to the bottom section that says questions (maybe glance at the third picture).
Here is an example of a machine:
I have two goals with using streaming enabled:
-
The data can be streamed in and out
- By “data” I mean the value Instances and remotes of a machine.
The BaseParts too would be an awesome added bonus. - This is to save client memory, most of the game’s memory is anticipated to be taken up by many machines’ data
- Will use binders/tags to manage machines going in and out
- By “data” I mean the value Instances and remotes of a machine.
-
Data is guaranteed to stream in fully, all at once
- It would also be great if there was a way I could assume that the entire machine model will be streamed in and out all at once.
- It is fairly important that the machine can be guaranteed to have all of its data on the client. I have a few work arounds I can implement, but they aren’t nearly as clean.
I have read the content streaming article and found some helpful information:
“When a player joins, all instances in the Workspace are sent to the client, excluding BaseParts and descendants of those instances. Then, during gameplay, the server streams in BaseParts and their descendants to the client.”
That would mean with my current structure, the Instances highlighted below would never be streamed in and out:
I can’t have all that data on all clients, so I am thinking about this structure:
(Where the parent Part just a non-collide hitbox around the machine.) This seems like a perfect solution, besides that the same article says to avoid exactly this:
“Avoid parenting a part to another part, especially when the parent is far away from the child. Instead, group them as a Model.”
I am also worried if all the Instances are streamed in all at once that there might be problems:
Avoid creating moving assemblies [which stream in all at once] with unnecessarily large numbers of instances, as all of the instances streaming in unison may cause network/CPU spikes.
It would be nice if there was an optimization or something that prebuilds the assemblies in nil, then time slices up the operation, then moves it to Workspace all at once. That might exist already though. I can also probably solve this problem with meshes or something though.
Questions
This comes to my technical questions about streaming enabled:
-
Are all of the descendants of a BasePart guaranteed to be streamed in with the BasePart (example, Folders, value Instances). Maybe just the non-BasePart descendants and their descendants? Maybe none are guaranteed? Edit: BasePart descendants aren’t guaranteed unless unanchored.
- (I know I can use attributes to guarantee some of this, but I also need remotes and object references.)
- Does parenting a part to another part disable some important optimizations? (I assume the article says “especially when the parent is far away from the child” because this streams the child in at the wrong times.) A significant amount of my game will be machines, so if streaming enabled isn’t acting as intended it will have a large impact.
- I am also curious if all the Instances are guaranteed to steam in at once that this will cause CPU or network spikes. The machines will probably have 10-30 parts and 15-45 instances (total).
I will be working on some testing and performance comparisons. If you know the answer to any of these questions or have any great sources (RGC talks, articles, forum posts, etc.) relating to StreamingEnabled those would be greatly appreciated.
Thanks a bunch
Research notes/edits:
Really hope that feature is coming