Real world building and scripting optimization for Roblox

First, the caveat: Don’t prematurely optimize, just use PivotTo until you’ve established that you’re moving around enough stuff for that to be a bottleneck.

To absolutely maximize perf moving non-physics-simulated objects:

  • If you have a lot of similar things which you want to move around, where the internal structure of each of those things does not change and is under your control: The fastest by far is to combine all the parts into a single assembly with Welds (root part anchored and others unanchored) and BulkMoveTo the RootParts of each of those assemblies.

  • If you have a bunch of assorted stuff whose behavior is not uniform, where you calculate the updated positions in different ways / at different times, same as above but set .CFrame on the root parts rather than spending extra effort setting up arrays for BulkMoveTo.

  • If you’re writing a tool / library, and have a model with unknown contents to move, use PivotTo on the model.

4 Likes

Anything behind the terrain in that screenshot is going to count towards the scene draw call count, as well as any ParticleEffects and Clouds (if you have a Clouds instance inside your terrain). But anything off-screen won’t be rendered.

just thought I’d let you know since the render stats you posted shows there are 26,243 other potential instances that might be rendering in your game :slight_smile:

BTW, if you wanna see exactly how much something is impacting render performance, try deleting it and noting the draw call count before and after. Also make sure you don’t have anything selected, since selections in studio impact performance rather heavily.

Regarding using terrain, most of the time a terrain will stay under 250 draws and 250k triangles. It just means if you’re going to use terrain, plan for it to be half your game :slight_smile:

1 Like

Appreciate the in depth detail,
Mostly definitely learned some new techniques. :index_pointing_at_the_viewer::sunglasses:

Useful for beginners. Though ultimately most will come to quickly realize that no, roblox does not exactly help you with those things nor it is exactly such a bangin’ engine. While these methods can help, ultimately they pale in comparison with what you could do to optimize in like every other 3D game engine out there EXCEPT roblox. We can’t even stream textures man! Talk about keeping the memory below 1.3 gigs yet we don’t even have a decent way to yknow, not run max resolution models on 2x2x2 stud models from like 200 studs away.

I’m not sure how you expect roblox to run at max graphics on a 2 gb of ram phone just via optimizing the standard toddler casino. The roblox client alone takes like tons of memory and any optimizations you could do can barely get the memory to budge at runtime. Anything you could do in studio CAN help a bit but ultimately youre still faced with the issue that the entire game world will always be held within memory without any proper way for you to ACTUALLY stream its contents in and out.

Also, streaming enabled is in fact, not good for very large maps (unless your definition for very large maps is like MAX 2048 studs of simple geometry). Streaming enabled in fact, sucks, and it sucks hard. Yet ultimately the roblox provided streaming is our only REAL way of actually making a difference due to the fact that the thing is actually capable of not loading the entire map when the client is loading, saving most users from memory related crashes. Streaming out everything is an entirely different story though (its slow and does nothing to improve memory afterwards).

Oh and im pretty sure meshes and unions are NOT as light as BaseParts as you might have said. From my experience with them they tend to be a double edged sword when it comes to optimization. It’s true that you could replace large part volumes with a singular mesh and save tons of performance however the same cannot be said about everything else. My general idea on how to properly use meshes and actually optimize them is in cases in which you could merge at least over 10 parts while also cutting down their geometry within blender or other 3D modeling software for further performance enhancements. But for short, a block BasePart is way easier to render than a block Mesh/Union. Same goes for all the other shapes. You should be conservative with meshes.

I dont know man, but i dont think youre being honest with yourself when you constantly boast about roblox. I don’t think roblox is trash but its clearly inferior to absolutely everything else out there. I’m just sayin, you could be getting paid more if we all had actually good proper ways of optimizing our games without make-believe optimizations (such as parenting stuff to nil to simulate the streaming in and out of geometry :confused: . Trust me, this is the only way i also have of optimizing my maps at runtime and it sure is a piss poor way of really doing things and won’t save systems with low memory).

Oh little nitpick but honestly it would have been nicer if these optimizations were applied to something else and not a super basic toddler casino. Those aren’t exactly hard to not make run like crap by default.