I’m making a game and I need it to have it so when you overlap with a tile something only happens once for the entire game.
Either replace that tile upon overlap or set a Boolean variable that’s false on initial game startup, then have an if statement to check if the Boolean is false, and if it is, perform the action and set the Boolean variable to true.
Welcome back! ![]()
The most common way I see this fixed is by creating a variable like ‘TileOverlapped’ and setting it to the boolean ‘false’ at the start of the game.
Then, when the player overlaps the tile, use an if statement to check if TileOverlapped is equal to false. If it is, the code inside the if statement will run (and do whatever you want overlapping the tile to do!)
Then, at the end of the code inside the if statement, set TileOverlapped to true.
That way, the code inside the if statement can only ever run once, because TileOverlapped will never be equal to false again!
Here’s a code version of this explanation:
Set a variable to “true” when the game starts. Then when the player overlaps with with the tile set it to false. Then place all of the code in the tile overlap loop within an if statement. Place your variable within the if statement’s condition.
You can make a variable like IfHappened and set it to true, and make it onlyh happen when it is true, and set to false once it is done.

