Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

100 3d coins in same scene - Performance effect

Discussion in 'iOS and tvOS' started by smkamran, May 24, 2012.

  1. smkamran

    smkamran

    Joined:
    Jun 21, 2010
    Posts:
    23
    Hi Guys,

    I m working on the clone of Coins Dozer. I have 80 to 100 coins the a scene but it is effecting the performance on
    iphone 3g. I m getting very low frame rate.

    Can you suggest me any solution to this problem?

    Using normal map is good for performnce or not on mobile devices?
     
  2. Unitard

    Unitard

    Joined:
    Jan 27, 2008
    Posts:
    29
    Why does Coin Dozer need to have a clone?
     
  3. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Use object pooling. Figure out roughly how many coins will ever be drawn on the screen at one time and create only that many instances. You can then keep track of where all your coins would be in the level and when they come into the camera's frustum you place one of the instances at those locations. Then when they object is no longer visible it goes back into the pool. With a little work you can even have your object pool create more coins on the fly. That way you can start with even fewer coins in memory and only instantiate more when needed so you don't have objects sitting around in memory that may never even be seen.
     
  4. Martin-Schultz

    Martin-Schultz

    Joined:
    Jan 10, 2006
    Posts:
    1,377
    I do the same and what you have to do is make sure all of them have the same material, don't rotate them individually, have one script to rotate them all, don't rotate their collider (!). That helped me a lot, but I limit it now to around 70 coins, 100 didn't work for me either.
     
  5. smkamran

    smkamran

    Joined:
    Jun 21, 2010
    Posts:
    23
    Thank you guys for your suggestions. I will get back to you soon...
     
  6. ezone

    ezone

    Joined:
    Mar 28, 2008
    Posts:
    331
    I'd lose the normal map and make sure the scale of all your coins is equal on all axes to ensure they are batched to a single draw call
     
  7. _Petroz

    _Petroz

    Joined:
    May 13, 2010
    Posts:
    730
  8. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Just passing values to the shader via the normal and tangent arrays of a mesh will break batching. Found that out the hard way when trying to be sneaky and pack extra data into them to allow more flexibility with a single material. This is contradictory to what is stated in the documentation.

    My objects are only 4 verts and batch just fine when not using normals or tangents, so guess this is also part of that bug.