Is higher script activity always a bad thing?

So I find myself in an interesting situation.

I wrote up a basic camera controller that ties a function to frame rate that handles updating the camera’s CFrame for animation (changes its CFrame to move left/right.)

Now, I noticed when I played on 120hz, the script activity spiked up pretty significantly. It got up around 3-4%. On 60hz, it was normal. And ultimately, the activity spike would grow the larger FPS I would set the game to run at.

I don’t really know if it’s a problem or not. It makes sense, as obviously the function will be executing twice as much. But I don’t know if that translates to performance loss. I’ve always heard 2-3% activity is the sweet spot.

But in regards to the logic I’m using, it should be fine? Literally all I do is update the CFrame of the model and change it. I noticed using PivotTo got quite hefty in terms of %, so I am now just setting the part’s CFrame directly.

What I ended up doing was capping the heartbeat to run at <= 60 times a second. A weird solution, because then the issue was trying to clamp the deltatime from the previous frame. (in the scenario the host machine is running above 60hz)

Weird situation. The logic is not expensive at all, I find it weird how the script activity spikes quite significantly.

Thanks for any insight.

1 Like

Now, I noticed when I played on 120hz, the script activity spiked up pretty significantly. It got up around 3-4%. On 60hz, it was normal. And ultimately, the activity spike would grow the larger FPS I would set the game to run at.

If the script is running locally and you increase your frame rate, the script activity will naturally increase w.r.t the number of frames per second your monitor needs to match your FPS. Heartbeat fires at the end of each frame, so you would expect a script with an event connected to Heartbeat to execute more when there are more frames to consider. Don’t mix up the settings; recall that frame rate is not equivalent to refresh rate.

Not a bad thing by any means. If you can support a higher frame rate, chances are the calculations on the client won’t be too extreme. If you’re worried about it your solution works fine, but keep in mind (like you’ve discovered) that machines using an FPS setting >60 won’t play nice with this unless you account for the time step. This is mentioned on the DevForum post that announced maximum frame rate adjustment.

2 Likes