Unity 2D - low fps in editor, 60+ fps in build - unity3d

we are developing platformer game in Unity engine. Currently in our scene are 15 npc, movement is animation based, they are navigated via scripts, they can talk to player, fight etc. Rigid body does not handle collisions, it just detects ground as a trigger. When build is created, all is nice and smooth 60fps, in editor it is 25 to 30, sometimes a lot lower which makes us sometimes a lot of problems. Do you have any experience how to make a game run smooth in editor? Thank you

if your editor is very slow you can go to the unity icon right click on it and select properties and in the target add -force-opengl in the end.
you can also increment the fps by
void Start()
{
//increase of fps
Application.targetFrameRate = 300;
}
for more info go to https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html
try to logout to unity becuase sometimes the login can make the editor running slow

Two top things are check that the profiler is not running and that the scene view is not open. These are the two most common causes (in my experience) of slow down in the editor.
You can also make sure there isn't any light baking going on, shouldn't be for 2D but worth checking.
Another thing to check is any editor only scripts, i.e. namespace UnityEditor.* usages (#if UNITY_EDITOR).
If you want an uncapped frame rate, go to project settings -> quality -> vsync mode, and turn off vsync.

Another option may be to turn off Gsync(Vsync) on your monitor and graphics card control panel

Try using Unity 2022.1.24f1, I get more fps in that build and also you can try using this free asset to get more fps.
https://assetstore.unity.com/packages/tools/utilities/frame-rate-booster-120660

Related

Is it possible to play your unity game in scene mode?

Hi I'm working on a simple 2D unity game and it would be so much easier to figure out problems if I could play my game in scene mode so that I could check on every object's values as I go. Is it at all possible to play your game in scene mode?
That is not possible, as of now, in the Unity engine. You would need to handle it yourself. Take the Unity's Cinemachine package as an example. You can tweak the values of a cinemachine virtual camera in-game and store the values as you tweak them if you check the "Save during play". The package is designed in a way that it preserves its state, so when you stop playing, it doesn't lose the changes you made in play mode. Moreover, Cinemachine gives you gizmos that you can tweak the values through the game viewport, not only the inspector.
You would need to do such things for your game so when you start playing, you can, for example, click the gizmos on a puzzle object and change where it sits in the scene, and when you stop playing, the tweaked position would be preserved.
You can read Inputs while being in a custom editor with for example:
if(Event.current.type == EventType.KeyDown
&& Event.current.keyCode == KeyCode.W) {...}
You can read all your wanted inputs and pass it on to your default input scripts. You could make whole games in just the inspector window or whereever you want, but if you should is another question...

Editor Loop delay. Is it a problem for my game?

I'm new on that thing of analisys profile of Unity. I decided to see if my player is dropping too much FPS and the I found this. Will that be a problem for my game? I don't know how that system works, but I guess 8.35 is a high number...
Not its not.
The editor loop is how long the unity editor took.
The player loop is (roughly) the performance of your game. And the big green part looks like the WaitForTargetFPS call to me. Though to tell for sure you'd have to expand the player loop and see.
If you want to measure the actual performance of your game accurately you have to make a development build and profile that one (you can select the debugging options for this in the build dialog).
Further reading: profiler documentation

Unity on Xbox One - Camera/Rigidbody Visual Movement Hiccup

This is posted here since this is Xbox specific, but I am also posting this onto the Unity forums.
When testing my Unity game on Xbox One I am getting a very large amount of visual "jitter" from the ball. This is a skeeball game where you control the movement of the ball. Essentially the core of the movement is similar to the Rollerball tutorials. On PC this works fine and there are no perceptible jitters. However, on Xbox, I am seeing this a lot more. The object is travelling large distances with the camera following smoothly behind. None of the other objects or scenery are affected, I actually think the camera itself is moving perfectly. But, the ball itself seems to glitch.
Changing my camera movement to LateUpdate seemed to minimize it the most on the PC, but that doesn't make sense to me since I am still not convinced the camera is the problem.
Any help would be greatly appreciated. Perhaps a quality setting isn't placing nice with the Xbox?
Thanks!
Nick
Keep in mind the clock speed of the CPU on the Xbox is likely much slower than your PC (although there are more cores).
Unity is primarily single threaded, so that could explain the performance difference. Here are some things you can try:
* Make sure you are running the "Master" build on Xbox. The default is "Debug" which is significantly slower.
* It's possible it's something with the physics.
Once you've checked to make sure you aren't running Debug, the next step would be to use the Unity profiler to see where your frame time is being spent, then depending on what the cause is optimize that part.
Here is more information on the system resources:
https://learn.microsoft.com/en-us/windows/uwp/xbox-apps/system-resource-allocation
There is also a great post about the graphics debugger here:
https://tarhik.wordpress.com/2017/09/04/antimatter-instance-dev-log-entry-2-using-microsofts-graphic-debugger/
It looks like switching the RigidBody to use "Extrapolate" instead of "Interpolate" fixed the issue I was seeing. I am not sure if this works for every situation, but for the scale of the levels and the player physics of my game this seemed to do the trick.

Is it more efficient to change scenes in Unity or to have different ui screens?

I've been working on a really simple game for iOS that has just three scenes; the start scene, game scene, and game over scene. I was running the game and analyzing performance with the profiler and I noticed that when I changed scenes, which utilized the "SceneManager.LoadLevelAsync()" function, the CPU usage was around 90%. This is only for less than a second of course, and then the CPU usage drops again and I get around 70-80 fps, but this got me wondering if it would be more efficient for a simple game like this for me to simply have several UI "screens" (basically just a group of objects that I can activate and inactivate), which is what I did with my pause screen (it is just an overlay).
Of course this could have difficulties of its own, like I would have to restart the game on the same scene but it might help me with my problem of running the mute function I've built on my music manager, which is instantiated in the start scene, from a button that is on my game scene, and I wouldn't have to use the "DontDestroyOnLoad()" function on the music manager or my score manager (which stores the score to be displayed on the game over scene). But would it be inefficient to have so many inactivated objects, or is Unity pretty good at managing things like that?
In my personal opinon, menu system should be in one scene.
Having different scenes for every menu screen will cause overhead. Even it is for few micro seconds it will affect user experience when navigating between menus frequently. This is because of loading and destroying of each UI gameObject in scene.
While menu system based in one scene requires only activating and deactivating of gameobjects instead of instantiating and destroying.
You can have one root object for menu and assign it a canvas component and then you can add different panels for each screen and assign them canvas groups to toggle them on and off smoothly.
Here is a good tutorial for creating menu system: https://www.youtube.com/watch?v=DNqTUwnpLvI
Hope this helps.
You are correct, If your game / app is small you should keep it as simple as possible, if the only difference between your scenes is just UI & your "in game" scene is not that big, you can for sure keep using the same scene and have the UI activate/deactivate.
*Inactive objects DO eat memory.

Unity 3D low fps

I'm using Unity3D 5.3 version. I'm working on a 2D "Endless running" game. It's working normally on PC. But when I compile it to my phone, all of my gameobjects are shaking when they are moving. Gameobjects are in a respawn loop. I'm increasing my Camera's transform position x. So when my camera is in action, all of the other objects look like they are shaking a lot and my game is working slowly on my phone as a result. I tried to play my game at Samsung, on discovery phones. It's working normally on some of them. But even on some Samsung devices it's still shaking. So i don't understand what the problem is. Can you help me with this?
One thing you can do is start optimising, if you have a game that is either finished or close to it. If you open the profiler, click "Deep Profile" and then run it in the editor on your PC, you'll get a very detailed breakdown of what is using the most resources within your game. Generally it's something like draw calls or the physics engine doing unnecessary work.
Another thing that might help is to use Time.deltaTime, if you aren't already. If the script that increases the transform doesn't multiply the increase by Time.deltaTime, then you're moving your camera by an amount per frame rather than per second, which means that if you have any framerate drops for any reason, the camera will move a smaller distance and that could be throwing out some of your other calculations. Using Time.deltaTime won't improve your framerate, but it will make your game framerate independant, which is very important.