Forum rules - please read before posting.

Random FrameRate FPS Spikes/FPS camera jumps

edited August 3 in Technical Q&A

@ChrisIceBox I'm a bit at my wit's end. I have a pretty beefy machine, and I have a pretty simple level going, getting an average FPS of 140.

But there are these odd spikes that cause the fps camera to 'get away from me' due to framerate spikes. This is both in the editor and the build. I attached a profiler to the build and I'm seeing these drastic spikes which seem to be indicate it's in the scripts, but it makes no sense. (image attached) I am able to run the latest games like Silent Hill remake on this machine without any issues.

2025-08-03-20-31-11-Profiler

The spikes in the profiler appear to be from the scripts. I'm using the latest AC, Unity 6.1, the AC FPS Character and the old input system.

Interestingly, I removed AC and used a generic FPS controller and it ran smooth. It seems there's something in AC that's causing this, but I've not had this before. I've built games using AC on older machines and didn't have these issues. Any idea on how I might troubleshoot would be very welcome at this point.

Comments

  • When I remove the profiler the spikes happens a lot less often, but it still happens.

  • edited August 4

    I had some complaints from people with powerful machines, saying that my 2D game made their GPU scream! I now have a game object Called ForceFrameRate with a script attached, in my 'Scene Zero' (the one that loads first) and it caps the frame rate to 120 (editable), here's the script, hopefully it helps:

    using UnityEngine;
    public class ForceFrameRate : MonoBehaviour {

    [SerializeField] bool forceFrameRate = true;
    [SerializeField] int frameRate = 60;
    bool check = false;
    ForceFrameRate[] duplicates;
    
    void Awake() {
        DontDestroyOnLoad(this);
        Application.targetFrameRate = frameRate;
        duplicates = FindObjectsOfType<ForceFrameRate>();
        foreach(ForceFrameRate e in duplicates) {
            if (e != this) {
                Destroy(e.gameObject);
            }
        }
    }
    

    }

  • Looks related to your Menus in some way. How many are being shown at the time the spikes show up?

    Does this occur if you temporarily swap your Menu Manager asset file to Default_MenuManager?

  • After a LOT of testing, I've narrowed it down to a combination of VSYNC and FRAMERATE capping. @Saturnine , thank you for pointing me in the right direction.

    When I used your script to cap the framerate to 60 FPS AND turned off VSYNC, the game build was stable, with no spikes/drops in framerate and the mouse look staying well in control. I also notice that my monitor's refresh switched to 63Hz on its own.

    When I cap the framerate to 100 FPS and turned off VSYNC, the screen tears, the monitor's refresh turns to 100 Hz, and the game build crashes.

    When turn on VSYNC, all hell breaks loose. The game build ignores the framerate cap (which I've read is expected behavior), and I'm getting FPS of 300+ and the mouse look goes crazy and there are massive dips in framerate. This has to do with a combination of VSYNC and monitor refresh. But I can't for the life of me figure out what.

    @ChrisIceBox I tried what you said and switching to default menu manager didn't make a lot of difference. Also note that that particular spike showed OnGUI() but each spike tells a different story in the profiler. In some cases it's the renderer.

    For now, I'm going to keep this capped at 60 fps and turn off VSYNC. But it worries me about what might happen when players turn on VSYNC. I'm not sure if this is new behavior with Unity 6. Or if it's because of my new faster dev PC, or if its' because of my monitor.

    Oddly, out of frustration, I installed Unreal and just ran its default FPS controller and it's buttery smooth. @ChrisIceBox if you ever port AC to Unreal, I'd really consider switching lol. Unity can be really frustrating at times.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.