physics at layer level?

Hi Dyson,

Is the “physics” layer property mean to make all tiles on that layer physics object?   Or does it just enable the layer for physics after which you have to set the tile (in the tileset) to have a physics property too?  

If not, is there another way to default any tiles in a particular layer to be physics objects?

The “physics” layer property used in conjunction with mte.enableBox2DPhysics(1) allows you to specify which layers run the physics objects and tiles you put on them. So, for example, you could give a platform tile physics properties, place it both in the foreground and in the background, and by only giving the foreground the “physics” layer property only have the tiles in the foreground generate physics bodies. It’s a convenience feature allowing you to use tiles as physics and non-physics tiles depending on the layer.

Only tiles with the “physics” tile property will load as physics objects. If you don’t specify any other properties the physics body will be static, rectangular, and the size of the tile.

thanks - sounds like you need to go through each tile (tile by tile) and add the physics property - be a bit lazy :slight_smile:  is there a way (if I’ve already got lots of tiles in a tileset) to force physics on for all tiles in the tileset?  

Just tried setting a property in Tiled across multiple tiles all at once and it doesn’t seem to work.  (perhaps a find and replace in the file itself?)

I’ve added forcePhysics layer property to my todo list for MTE development, though it is a little ways down it. Of course, forcing every tile to be a physics object will make a whole bunch of boring, static, rectangular objects (unless you specify each tile’s shape, etc). If you have any suggestions for how you’d like the property to work let me know!

The “physics” layer property used in conjunction with mte.enableBox2DPhysics(1) allows you to specify which layers run the physics objects and tiles you put on them. So, for example, you could give a platform tile physics properties, place it both in the foreground and in the background, and by only giving the foreground the “physics” layer property only have the tiles in the foreground generate physics bodies. It’s a convenience feature allowing you to use tiles as physics and non-physics tiles depending on the layer.

Only tiles with the “physics” tile property will load as physics objects. If you don’t specify any other properties the physics body will be static, rectangular, and the size of the tile.

thanks - sounds like you need to go through each tile (tile by tile) and add the physics property - be a bit lazy :slight_smile:  is there a way (if I’ve already got lots of tiles in a tileset) to force physics on for all tiles in the tileset?  

Just tried setting a property in Tiled across multiple tiles all at once and it doesn’t seem to work.  (perhaps a find and replace in the file itself?)

I’ve added forcePhysics layer property to my todo list for MTE development, though it is a little ways down it. Of course, forcing every tile to be a physics object will make a whole bunch of boring, static, rectangular objects (unless you specify each tile’s shape, etc). If you have any suggestions for how you’d like the property to work let me know!