Optimizing animations

External Media

In my game we want to animate individual machines that are placed on player bases
The problem is that machines can be densely packed together, and that can cause a lot of lag

Right now, I am just using Roblox animations because they seemed like the easiest option, and I thought they would be the fastest (because they are ran in C++?)
To animate the machines in the clip, I just have a server script inside of each machine’s animationcontroller with one line:

script.Parent:LoadAnimation(script.active):Play()

I am wondering what you guys have done in the past and what works best

For example, does not playing animations for occluded machines improve performance?

Would a custom animation system be faster than Roblox’s defualt animation system? If so, is Motor6D.Transform the fastest way to update cframes?
Should I lower the FPS of faraway animations, and is it possible to do so through the Roblox animation system? If it’s not directly possible to lower the FPS through the Roblox animation system, what if we manually (well, programmatically) make a separate set of animations that have the same CFrames for many frames in a row? Would that be less intensive?

I would like the machines to keep their Roblox material textures if possible, but I am open to substituting the meshparts (btw everything is a meshpart) with SpecialMeshes and using scale and offset for farther away machines if it improves performance

1 Like

Yeah, just stop the animations when the player goes too far away. Do an update check for all machines every second or so to decide whether to play/stop animation.

No, that doesn’t help. The motor is animated every frame regardless (cframe is set), does not matter how many keyframes there are in your animation.

It’s a lot of work for uncertain benefit. Setting Motor6D would be the fastest if you go the custom route yeah. Probably wouldn’t try this if the “stop when far away” already works for you.

3 Likes

So if you set the same CFrame over and over there is no difference versus setting a new CFrame?

For small displacements / small parts there is no measurable cost difference between slightly moving it or keeping it still.

For large parts or constant large displacements, the physics subsystem needs to constantly update the buckets in space that the part occupies, which makes it (probably) slower to move it further away than setting the cframe to the same value constantly.

For your example it seems like they are small parts and they move minorly so this aspect of performance should not be something you have to think about.

3 Likes