Search Unity

Is ECS or Hybrid ECS for my project?

Discussion in 'Entity Component System' started by Blueknight1758, Apr 16, 2019.

  1. Blueknight1758

    Blueknight1758

    Joined:
    Jul 27, 2013
    Posts:
    13
    My project involves reading a heightmap and a hexagonal grid is generated with each pixel representing a hexagon, and the pixels colour representing the tiles height.

    Currently each hexagon is an instantiated prefab variant (variant based off of height, low height = water, medium height = grass, high height = stone/snow).
    The prefabs do little more than have a collider, material (GPU Instanced) and a position.

    In my head ECS would greatly improve the performance of this project as the current greatest issue is lagspikes when instantiating new prefabs, and low fps if trying to render too many at once.
    (My tests indicate I might be able to to render up to a 250 x 250 grid compared to a 125 x 125 I currently can)
    However i've been unable to find a way of using ECS with colliders, is this currently possible?
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    Is it possible? Yes. Is it easy? Well that depends on what you need the colliders for. Unity.Physics is a physics engine for ECS. That might meet your needs. If you are just placing the hexagons along the heightmap every once in a while, using GameObjects that only have the colliders and don't have the rendering information, and then using entities for the presentation might help you solve the low FPS. The lag spikes suggest you need to pool your GameObjects.
     
  3. Blueknight1758

    Blueknight1758

    Joined:
    Jul 27, 2013
    Posts:
    13
    I need the colliders so the player can walk around the terrain.I'm investigating pooling the objects, but main bottlekneck right now is loading that many at once, so I will investigate your suggestion.