Hi all,
i’ve been wondering if there is a way to limit the framerate of my VisualEffects in Unity.
Our game has a hand-drawn look, and we feel the VFX would fit better if they are not running at 60-120fps.
I already have a “quantized delta time” that simulates 30fps by moving in 0.0333 steps and being 0 in the frames inbetween. So defining the deltaTime that the VFX Graph should run on would work for me.
I already looked at the API and got it working like this:
public class ConVfxGraphLimitFramerate : ConMonoBehaviour
{
[SerializeField] private VisualEffect vfx;
private void Update()
{
vfx.pause = true;
if (ConTime.TimeDeltaQuantized > 0F)
vfx.Simulate(ConTime.TimeDeltaQuantized);
}
}
However I’m not sure if this will hurt performance. From what I can tell in the Profiler, VFX uses the Jobs API so it is probably running multithreaded? The way I’m doing it here I’d move the calculations to the main thread, right?
Alternatively I could use the playRate
property to achieve the same effect:
vfx.playRate = ConTime.TimeDeltaQuantized / Time.deltaTime;
The vfx updates with Time.deltaTime * playRate
and also seems to run after LateUpdate
(correct me if i’m wrong), so this would have the same effect, while not moving the simulation process into my Update loop.
Just looking for some feedback on what you think might be the best approach for this problem.
Thanks!
Edit: Would also interesting to know if there is a way to modify the playRate of all VisualEffects globally. That way I would avoid having a separate Component on every VisualEffect that limits the PlayRate. Alternatively is there a list of all existing VisualEffects in the Scene or do I need to collect them myself?