Entering building in a 2d platformer

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

Hi guys,
I’m doing a platformer and I’m trying to do some buildings, i want that when i’m far from the building I have to see the “outside” wall and when i’m quite near I can see inside.
There is a way to do that?
Sorry for my bad english

What I would do is measure how far the player is from the buildings. When the player is far from the buildings, change the alpha value of the self_modulate property of the building image to 0. As the player gets closer to the building, slowly increase this value to 255.

Hope that helps.

Ertain | 2020-05-06 23:40

I did read recently that it’s quicker to use built in features, such as an area2d entered signal rather than keep checking distances.
Plus if you have a lot of buildings, you could put an extended area2d around the building that when the player enters, you do what @Ertain said above.

deaton64 | 2020-05-07 09:02