Skip to content

Commit

Permalink
changed order of composite collider
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammin committed Sep 25, 2023
1 parent f3b29a4 commit ca9d482
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Assets/LDtkUnity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Updated json support for LDtk 1.4
- Fixed a compile error if Unity's Aseprite importer is also installed
- Fixed an issue where the tileset file export app wasn't able to run on MacOS
- Switched the order of the TilemapCollider2D and CompositeCollider2D in layers to resolve a [physics issue](https://forum.unity.com/threads/tilemap-collider-with-composite-doesnt-work-with-particle-system-collision-trigger.833737/#post-9173561) for particles

# 4.0.0
###### September 22, 2023
Expand Down
8 changes: 6 additions & 2 deletions Assets/LDtkUnity/Editor/Builders/LDtkBuilderLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected void AddLayerOffset(Tilemap tilemap)

protected void AddTilemapCollider(GameObject tilemapGameObject)
{
TilemapCollider2D collider = tilemapGameObject.AddComponent<TilemapCollider2D>();
//intentionally making the order of the composite collider first because of issues with physics particles:
//https://forum.unity.com/threads/tilemap-collider-with-composite-doesnt-work-with-particle-system-collision-trigger.833737/#post-9173561

if (Project.UseCompositeCollider)
{
Expand All @@ -62,13 +63,16 @@ protected void AddTilemapCollider(GameObject tilemapGameObject)
CompositeCollider2D composite = tilemapGameObject.AddComponent<CompositeCollider2D>();
composite.geometryType = Project.GeometryType;

TilemapCollider2D collider = tilemapGameObject.AddComponent<TilemapCollider2D>();
#if UNITY_2023_1_OR_NEWER
collider.compositeOperation = Collider2D.CompositeOperation.Merge;
#else
collider.usedByComposite = true;
#endif

return;
}

tilemapGameObject.AddComponent<TilemapCollider2D>();
}
}
}

0 comments on commit ca9d482

Please sign in to comment.