Let's say I'm developing a horror game. For a jumpscare when entering room #1, the easiest way would be like this example:
void gameLoop() {
if (playerEntersRoom1 && !playerHasBeenInRoom1) {
playerHasBeenInRoom1 = true;
jumpscareForRoom1();
}
}
However this doesn't seem like a good solution to me, especially because the code would become quiet large when adding more and more of such events at some point. What's the way to go in a game engine like Unity?