Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AltSim · Apr 03, 2013 at 01:16 PM · low fps

low fps when looking in a direction with many objects

Hello!

I have an annoying problem with my Unity game. My Problem:

I have many objects in my game (cubes, cylinders). When I'm looking with the 1st Person Controller in a direction with less objects, everything is fine^^ High fps.

But when I'm looking in a direction with many objects, the fps decreases to ~5 to 10 fps. I have set the objects by hand, not by script.

So I dont know what's the problem. :(

Hope you can help me.

P.S. Sry 4 grammar (I'm Austrian)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Azial · Apr 03, 2013 at 04:31 PM

That's normal, because the render engine is rendering everything the camera faces, even if the objects are behind something. With Unity Pro you can setup Occlusion Culling which calculates at runtime wether objects are seen by the camera. I have only the free version, so I made my own "fake occlusion culling". The script is below. Use: make a new gameobject and drag all other objects that causes the framedropping into this gameobject als childs. Now attach the script on the gameobject. If you haven't any important script on your objects you want to cul, then don't check the "soft culling" checkbox, this would deactivate the objects in the distance. If you check this option, only the renderer components on the objects get deactivated in the distance.

 var culRange : int = 100;
 var softCulling : boolean = false;
 
 function OnEnable() {
     for(var toCul : Transform in transform) { //get all objects we want to cul. Place them as childs of the gamobject that's script is attched
         TurnOnOff(toCul, false);
         CheckRange(toCul, 0);
     }
 }
 
 function CheckRange(toCul : Transform, waitFor : int) : IEnumerator {
     yield WaitForSeconds(waitFor);
     var curRange : int = Vector3.Distance(Camera.main.transform.position, toCul.position); //range from the camera to the object
     if (curRange < culRange) { //if in range acivate/make visible
         TurnOnOff(toCul, true);
     } else { //out of range -> deactivate/invisible
         TurnOnOff(toCul, false);
     }
     var checkIn = Mathf.Max(0.5, 5*curRange/culRange); //the next check depends on the range from the camera to the object (for better performance)
     //print("Check for " + toCul.name + " in " + checkIn + " seconds."); //for debug
     CheckRange(toCul, checkIn);
 }
 
 function TurnOnOff(toCul : Transform, state : boolean) {
     if (!softCulling) {
         toCul.gameObject.SetActive(state); //deactivate the object(s)
     } else {
         for (var r : Renderer in toCul.GetComponentsInChildren(Renderer)) {
               r.enabled = state; //make the object(s) invisible
         }
     }
 }
 
 function OnDrawGizmosSelected () { //draw a debug sphere to visualize the culRange, not needed for functionality
     Gizmos.color = Color.yellow;
     for(var toCul : Transform in transform) {
          Gizmos.DrawWireSphere(toCul.position, culRange);
     }
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AltSim · Apr 06, 2013 at 04:08 PM 0
Share

Thank you for the hint with the Occlusion Culling :) Now it works fine with high FPS

avatar image AltSim · Apr 06, 2013 at 04:38 PM 0
Share

Hi!

Now it works fine with the Occlusion Culling :) The FPS are much much better than before.

avatar image
0

Answer by Statement · Apr 03, 2013 at 04:20 PM

Well, the problem is likely that you have too many draw calls, that you're rendering a lot of triangles or that your shaders are very complex, or a combination thereof.

You need to optimize your game.

http://docs.unity3d.com/Documentation/Manual/OptimizingGraphicsPerformance.html http://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html

What does the stats window say (see button in game window that says "Stats")?

Do you have Unity Pro or Trial and can use the profiler?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AltSim · Apr 03, 2013 at 06:34 PM 0
Share

Thanks, I think that's the problem. I will take a look on it at weekend and post it, if it was helpfully!
And yes, I have Unity Pro.

avatar image AltSim · Apr 05, 2013 at 04:21 PM 0
Share

Hello!

Here I have 2 pic of the stats window and the profiler:

profiler stats window

As you can see the fps are very low when I'm looking in a direction with many objects.

I'm going to try it with a combineCildren script. I hope it will works :-/

manyobjects.jpg (27.7 kB)
profiler.jpg (285.5 kB)
avatar image EliteMossy · Apr 06, 2013 at 06:12 PM 0
Share

You might be better to batch materials/textures to reduce draw calls if it is possible.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Low FPS after loading a scene 1 Answer

Scroll rect on mobile? 0 Answers

Low Fps in a simple game 1 Answer

Blank scene, 2 sprites, 32 FPS 2 Answers

Serious performance issues 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges