Search Unity

Feedback Sprite Shape Composite Collider 2D

Discussion in '2D' started by MousePods, Feb 7, 2022.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Hi,

    I noticed that I cannot check useByComposite on a sprite shape with an EdgeCollider2D. Is this a feature that is coming or just a limitation?

    Quick Question:

    I have 3 large terrain sprite shapes parented to one GameObject. I wanted to add a CompositeCollider2D to the parent and then check useByComposite on all 3 sprite shapes.

    Is it more optimized to use the composite collider (if it were possible) or keeping the 3 edge colliders separate?

    Thanks!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    CompositeColldier2D works on BoxCollider2D or PolygonCollider2D. You cannot use an EdgeCollider2D because the CompositeCollider2D can produce Edges or Polygons. We cannot turn an edge into a polygon.

    Use the PolygonCollider2D for your terrain SpriteShapes. You can then set your CompositeCollider2D to turn those into edges (Outlines).

    Optimized in what way? Depends on what you're doing. If they don't move to do anything then they still produce the same number of edge shapes.

    In the end, the physics engine knows nothing about Unity Colliders, it only has 4 primitivate physics shapes it knows about: Edge, Capsule, Circle & Polygon.
     
    MousePods likes this.
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Got it! That all makes sense and gives me a clearer picture of what is going on.

    Thank you :)
     
    MelvMay likes this.