if there are too manu gameObjects in the scene but are disabled will it slow down the game ?

so there’s a player, and there are too many enemies, lets say 100, at different locations in the map. as player gets close enough to one of the enemy, enemy attacks the player, otherwise enemy stays still.
but when I play the scene, it lags a lot.
so I was thinking, if I disable all the enemies and are set active only when player gets close enough, so that way there is only 1 enemy and 1 player in the scene at a time, will it stop lagging? or disabled gameobjects still consumes processing power ?

That’s a good idea. You’ll likely get a lot of improvement in frame rates.
You should probably read about Object Pooling for a better implementation of your idea.

look at the scripts attached to each enemy, and in those scripts, look for these 3 methods:

Update()

FixedUpdate()

:Lateupdate();

When you set “enabled = false” for those scripts, the 3 methods above won’t be called/executed. So, you may still be able to have the enemy move if it has a navmeshagent and/or animator. So I’d first try to disable (and not SetActive(false)) the enemy scripts (but keep the enemy game objects active) and see if the lagging goes away. If it does, try enabling each script, one-by-one, and testing. If you can find out what script is causing the lagging, look at the code in each of those 3 methods and see if you can find out what is causing the performance hit. However, if the lagging is still there after disabling the scripts/components, you may be running into a rendering issue (maybe your enemies have meshes with a very high LOD). If it’s a rendering issue, repost your problem to be restated for rendering issues (sorry, that’s out of my depth, but reposting as a rendering issue will target those who have the expertise to suggest rendering performance solutions).