Annoraaq / grid-engine

A grid based movement engine compatible with Phaser3.
https://annoraaq.github.io/grid-engine/
Apache License 2.0
235 stars 20 forks source link

pipeline "Light2D" does not work correctly #462

Closed Dead-TR closed 9 months ago

Dead-TR commented 9 months ago

If I assign the 'ge_heightShift' parameter to a layer in Tiled, lighting will not work on that layer. I understand that this is intended for overlapping objects, but is there a way to disable this? Or is it detailed somewhere in the documentation? image image

Dead-TR commented 9 months ago

If I remove "ge_heightShift" then the light works. But, obviously, this is not a solution to the problem. image

Annoraaq commented 9 months ago

I am not entirely sure how Light2D works. ge_heightShift will create one layer for each tile row under the hood. The only way to disable ge_heightShift is to remove it from the tile map.

I assume you want to keep it but fix the lighting? Can Light2D be applied to several layers at once? That would solve the problem but I am not sure about the performance.

Dead-TR commented 9 months ago

image image

The grid engine overlay operates using a pipeline, the same as Light2D. Because of this, I cannot simultaneously use both systems. However, since I don't want to abandon the grid engine, I will build a custom solution for the overlay. But, I think it should be mentioned.

Annoraaq commented 9 months ago

Grid Engine does not explicitly set a pipeline. It is simply calling Tilemap.createBlankLayer to create the extra layers. If you check out the MultiPipeline in the phaser docs it says:

Virtually all Game Objects use this pipeline by default, including Sprites, Graphics and Tilemaps.

I see this as a pure Phaser thing which does not need to be mentioned again in Grid Engine. Or did you want to say that you think in the docs we should be mentioning the fact that multiple tile layers are created for the height shift?

Dead-TR commented 9 months ago

Indeed, you are right. It seems to be something that works inside the Phaser. I don't understand why, but if I additionally specify "setPipeline" at the end of "create", then everything works as it should. Thank you

this.tilemap?.layers.forEach((layer) => layer.tilemapLayer.setPipeline("Light2D"), );

image

Dead-TR commented 9 months ago

Previously, I called "setPipeline" immediately after "createLayer". Looks like that was the problem. Thanks for the help!

Annoraaq commented 9 months ago

You're welcome.

Probably you called it before GridEngine.create? Because that will create the additional tile layers.