defold / defold/defold

Add "Collisions" enabling property for tilemaps layers, which allows to respect collision shapes regardless of visibility state

Open
#6,405 2 comments 1 reaction 0 assignees View on GitHub
box2d editor engine feature request physics tilemap
Dominant language
C++
Stars
6.3k
Forks
455
Avg merge
2d 2h
Merged PRs (30d)
129

Description

Background topic on forum: https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653

Problem:
When one is using two layers for game - one to represent collisions (often with basic shapes, like square or triangle) and one to represent visually the level (often with various shapes and edges), sometimes can happen, that visual representation layer is not covering the background collision layer, even if I set collision layer z under visual layer (mainly because of artistic vs practical aspects).
Problem is, that even if we make collisions on separate layer, we can not switch its visibility, because collision shapes are then not respected by physics engine.

Workaround:
To prevent this I can use different image(tilesource) for collision source and different for visual tiles. However for large maps/sources and in the development phase (when map can change a lot) this is cumbersome, as I always need to remember about eventually updating collision tilesource. Even though collision tiles are few, I can't make a smaller image for tilesource and reuse it for all visual representation, because the two tilesources (for collisions and visual representation) must have matching dimensions.

Idea:
One solution would be to allow to disable visibility of a layer (e.g. collision layer), without affecting collision shapes. For now there is only one property for visibility for tilemaps layers: Visible

It would be great to **add another boolean property here for tilemaps layers called for example: "Collisions"**
which if set to true, will tell physics engine to respect collision shape of the layer, regardless of property "Visible".

In this setup we could make a layer with collision shapes according to the tilesource, but the layer will not be visible in game ("Collisions": true, "Visible": false)

P.S. Another helping solution would be to allow tilesources of different sizes to be in tilemap for collisions (but row size must be identical, so order is maintained).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.