Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2d polygon collider and mesh update performance optimization for mobile

Discussion in '2D' started by Lordinarius, Feb 22, 2014.

  1. Lordinarius

    Lordinarius

    Joined:
    Sep 3, 2012
    Posts:
    94
    Hi. I am making a 2d terrain tool for my project and asset store. The tool is generating terrain data proceduraly then applying it to mesh and polygon collider. But when updating mesh and collider data, that is making lag on mobile phone(Galaxy s3). I need to generate the terrain fluently when vehicle is going through the map Could you give me some pro tips about that subject.

    Thats my process

    Generate perlin noise >>> apply data >>> update all mesh and collider

    in this video collider and mesh has 200 verticles. It is not laggy on pc .

     
    Last edited: Feb 22, 2014
  2. Lordinarius

    Lordinarius

    Joined:
    Sep 3, 2012
    Posts:
    94
    I splitted the terrain to 5 meters blocks (The terrain 100 meters) . Updating the hindmost only, and bringing it to the forward. it looks perfect now. No lags on galaxy s3. If you have more efficient advices i am waiting for it

     
  3. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,539
    Generating dense polygon data like that on mobile while the game is running, is going to cause lag... You could use EdgeCollider2D instead maybe, and set it's .points based on the boundaries of your the texture. Would involve a bit more math though.