Performance-aware tick event on PVInstance

Consider: Your game has 4000 coins that bob up and down. You probably don’t need the ones miles away from the player to be moving every frame, but you want the closer ones to do this.

Roblox already pays attention to performance and throttles effects and animations when things are far away. It does this based on device specs and user graphics settings. There should be an event on PVInstance that lets developers plug custom animations into this behavior.

12 Likes

Or you can be smart enough and simply calculate the difference from camera to decide wether to apply such things.
Plenty of small and top experiences already do that.

3 Likes

While a built in method would be cool, its still perfectly reasonable to just write your own system that does just that, and allows you to fully configure it to your needs more than you’d be able to with an engine event.

Paying attention to performance, this will degrade it. Why? Because to implement this, engine will need send additional signal about change. More work = less performant. Even if you not connected anything to it, it will still at least check if you connected something. Checking also takes some performance.
On devforum, there was one detailed post about how to do this.

The idea of a game collaborating with the engine to optimise performance is pretty cool and I’d hope to see some new ideas in that space, so long as they’re high level enough that they don’t force the engine to honour too specific contracts.

3 Likes

I like this idea and I see great use in it.
You could technically just write this in plain Lua, however there’s a bit of a problem.

If you have 10,000 coins with an spinning/bobbing animation,
comparing distance to the player with all of them is slooooooowwwww.

And it only gets slower the more coins you have.
Loops have their limits, they get more expensive and slower the more objects you have.

It doesn’t matter if objects are placed near or far away from each other, they ALWAYS make looping through them slower.

A solution: chunk-based updating?

Chuck-based object updating, it’s perhaps better than cycling through 10,000 coins in a loop.

Why?
Instead of looping through ALL objects in a game, you only loop/update the ones that are close to you in a chunk.

Chunk-based updating is very efficient.
Because it only scans/loops through chunks that are near you.

Objects and chunks that are miles away are completely ignored/not updated at all and therefor having more objects will not impact performance unless they’re all densely placed together in a single chunk.

But writing chunk-based updating systems is inconvenient, time-consuming and complicated.

It would be super neat if Roblox just had a built-in feature for this.
A tick/update function that’s somewhat distance-based from the player and doesn’t get more expensive the more objects there are.