useing area2d to let the objects invisible when the player is behinds it. it starts the game with them being invisible

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

Let me explain it better
So I’m trying to make the building disappears or transparent when the player goes behind it and when I use area2d, body enters and exits it works fine but when I start the game it makes the building invisible and when I enter and exit then it works fine
I know I should be using if
But I have no idea how.
So how do I make the building visible in the start of the game and invisible when the player enters.
I think it’s simple but I’m a beginner I don’t know much about gd script
Please give me an easy answer cuz my small brain doesn’t handle too much
Ohh btw it is a top down 2d game

What is making the buildings invisible when the game starts? I assume you’ve either 1) set their initial state to invisible (via the inspector) or 2) you have code that’s making them invisible on game start.

The easy answer is “don’t do that”. However, without knowing what is making them invisible on start, it’s hard to offer specific advice…

jgodfrey | 2023-02-06 23:31

That’s why I asked that
There is nothing making it invisible
But I used area 2d to send a signal when the player enters when they do the building should be invisible
And I know that’s why it is like that but how to fix it I have no clue

GrumpyIdiot | 2023-02-07 13:13

:bust_in_silhouette: Reply From: Gluon

Well as jgodfrey said the answer could depend on what is causing them to be invisible from the start. You could try adding a script to a parent node to set them all as visible e.g.

func _ready():
    $buildingnode.visible = true

This may work if you have set them to invisible to start in the editor for instance but it would be better to find out what is causing them to be invisible and just fix that.

I tried that but not on the parent, but yeah I’ll give it a try.

GrumpyIdiot | 2023-02-07 13:14

Okay if it doesnt work try posting your code here and maybe we can help

Gluon | 2023-02-07 13:27