- Home /
How do I turn a part of the tilemap full black to restrict the player from seeing it?
Hey everyone,
I'm making a 2D platformer and I'm dividing rooms with doors. I want to restrict what player sees on the other side of the door until the player opens the door using the trigger before it. That is, I want to turn the whole room dark, and when the door opens, an animation plays as the darkness disappears and the room is revealed. I'm not sure how exactly do you call this feature, it's similar to a fog of war. The whole level is made up from multiple tilemaps.
To provide an example, you can take a look at any Enter the Gungeon gameplay how the player enters a new unopened room. I want to do pretty much the same.
Answer by logicandchaos · Jan 23, 2020 at 01:42 AM
I would just overlay a black sprite over top. Then you can enable and disable it as needed. Like in your pic above you make a black sprite the size and shape of your room and then you reference it in a script, you can call it shadow, then when you open the door you can call shadow.gameObject.SetActive(false); and when you close the door you can call shadow.gameObject.SetActive(true);
Your answer
Follow this Question
Related Questions
Building a room, Textures Strech 1 Answer
Is it possible to create a hole for a door in a wall-like cube? 2 Answers
2d Platform game 2 Answers
Rotating A Character 180 Degress 1 Answer
Add Physics to Character Movement 0 Answers