How do I show/outline my player when the TileMap is covering the player sprite?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By unicornsoftwareinc

Hi there, I have an isometric game I’m working on. One problem I have is that the player and enemies can get hidden from view by the walls on my TileMap. The pictures below shows what I have currently, as you can see the wall is partially covering the player sprite.

What I have

But I want to have something like the picture below instead (I just did this in Photoshop). As you can see, the player sprite is visible through the wall, essentially making it look like the opacity of the wall is lowered for that specific section where it intersects with the player sprite.
What I want

I tried changing the z-index of my sprite which does get the player to show above the wall TileMap at all times but then it just looks broken.

An outline effect would also work for my use case. Any ideas on how to implement this in Godot?


:bust_in_silhouette: Reply From: Gluon

Create a separate sprite which is the same sprite but mostly see through. Write a script so that the new sprite exactly equals the position and animation state of the player (you will need signals between the sprite and the player so that the new sprite can change animations with the main sprite). Once you have this have the new sprite on the z-axis above all the backgrounds. When you can see both it will just look like the player but when you go behind a wall you will only see the transparent sprite above the wall.

Actually I have thought about it a bit more and you might find it easier to add an area 2D to your wall and then add an animation which just makes the wall turn partly translucent (add alpha to the sprite). When a player or enemy comes into contact with the area 2d trigger the animation and when they leave that area have the animation reverse back.

Gluon | 2021-11-15 22:46