Search Unity

Framerate good on phone, bad on PC??

Discussion in 'Android' started by mikesawicki64, Oct 18, 2017.

  1. mikesawicki64

    mikesawicki64

    Joined:
    May 12, 2014
    Posts:
    33
    I'm noticing a 102ms performance hit when my player encounters an object in the world - this causes a visible/obvious lag in the game, but only on my PC (in the editor). When I play test this on my phone (Pixel XL), there isn't an apparent frame hit

    The reason for the lag is because when the player encounters an object, I load that objects "icon" from Resources and add it to the inventory screen - but I do so by raycasting to all inventory slots in a list until the raycast finds an open place to put the icon. This is a larger than normal icon, so there are 4 raycast targets per "space check"



    I'm wondering why I notice this lag on my PC, but not on my phone?

    Any alternative ideas for adding multi-sized objects to inventory also welcome : |

    Thanks for any insight
     

    Attached Files:

    • fps.jpg
      fps.jpg
      File size:
      61 KB
      Views:
      684
  2. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    353
    When you say "raycast" - you mean iterating over the list that represents your player inventory in your game (and if you find a free slot you check the neighbouring slots?)* Even if there is a few thousand slots that'd well under a millisecond.

    Could the issue be actually loading the resource from disk, perhaps your phone is loading a compressed texture (already in a format ready for the GPU) from an SSD (no seek time) and your PC is loading say a PNG from a mechanical harddisk (seek time, then decompress the PNG, perhaps build mip mips and stuff...) and the reason this kills your frame rate is you aren't say doing it asynchronously?

    *I ask because I can't understand how raycasting applies to an inventory system
     
  3. mikesawicki64

    mikesawicki64

    Joined:
    May 12, 2014
    Posts:
    33
    Sounds like a totally viable explination as to why there was a difference in framerates - I've since found a way to replace raycasting and achieve the same result, but thanks for your feedback, it's a ueful theory

    All of the UI slots were essentially 10x10 sprites positioned in a grid within the inventory canvas - each slot had a collider, and when an object was collected I added an icon to one of these slots and deemed it "occupied" - I was raycasting to these slots to see if they were "occupied" or not, but as mentioned above found a much more efficient way to do this. thanks again!