Read-only variables/constants

We can define variables globally, or at the scene or object level. But they can be changed throughout the event sheet. I wonder if there’s a use case for defining constants, or read-only variables…?

In my game, for example, I have a global variable grid_size that’s set to 64 (the size of the grid my game uses). I use this value throughout my game for moving objects around (adding or subtracting GlobalVariable(grid_size) from their X or Y position) and checking for objects around my player (e.g. Object.X(); Object.Y() + GlobalVariable(grid_size) is inside Object2). Obviously I never want this value to change during the game, so I don’t have any actions that change it. But I wonder if declaring it as a constant/read-only variable would be safer…

2 Likes