While creating a 2D platformer, the idea of incorporating respawn points with unique abilities crossed my mind. However, I aimed to ensure that the feature was bug-free and prevented players from exploiting it by repeatedly triggering the points to acquire abilities indefinitely.
Hi Malay,
The computer cannot remember anything. If you want to check if something has happened before, you have to assign that information to a variable. Then you can read the value of the variable at runtime to figure out if something has happened before according to the logic of your code.
See also:
- Forum User Guides : How to mark a topic as solved
There is a trick you could use if you want a trigger to only be used once; Destroy the trigger once it’s been used.
Delaying the destruction of the object may not be effective as the player can repeatedly enter during that time and reset the timer. Additionally, the object is meant to serve as a checkpoint and not be destroyed. However, an immediate destruction can be a solution if needed.
I was able to fix the issue by following a tutorial on YouTube. I learned that I needed to create a new script specifically for the checkpoint and assign a public boolean to track whether it had been activated or not. This information was then used in my PlayerMovement script to disable the player’s special ability.
Good job!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.