How would i make outlines appear only on sides that arent touching other sprites?(SOLVED)

In my game the player will be able to place things and i want them to have black outlines but i dont want the outlines to overlap with the outlines of the block next to it.
Like this.

First off, I’m interested in hearing what others have to say, but my own way of fixing this is a little complicated. I would make it so that when multiple objects were close, they would have a separate larger object created in their place that was a Tiled Sprite using the same image and an Outline shader. So if you place two 64x64 objects horizontally, you would have to place a Tiled Sprite that was 128x64 in the place of the two objects, then delete the two previous objects.

This would fix the problem for simpler uses, but is a bit of a restrictive solution for more complex projects, especially ones using a variety of different objects.

I’m sure one of the generative or procedural pros will chime in. You can try searching for either term.

You can use 4 animations; all 4 sides, a left end, a right end and an animation without ends just a top and bottom line. Then it’s a matter of changing the animations based on neighboring objects.

How you go about efficiently checking which object is next to which object is another story.

1 Like

I have 2 other suggestions you can try.

The fastest and easiest way is to set the outline effect on the layer itself instead of the objects. This will apply an outline to the objects as a unified object. Keep in mind that this will set an outline on ALL the objects on the layer, so make sure the blocks are placed on their own layer with the effect applied to it.

If you can’t put the blocks on their own layer and the layer has other objects you don’t want to outline:

  • create a new block object with the outline applied to it (let’s say it’s called BlockOutline)
  • When you place any block, create an BlockOutline along with it in the same position and size
  • Stick it to the main block, this is in case you want to move or remove blocks.
  • Set the ZOrder of the BlockOutline to be BELOW ALL the blocks.

the first solution is perfect for me, thx

1 Like

Using layer effects can also save a bunch on processing time if you have a lot of objects that all need the same effect.