# 7. Power-Up and Unlock Pitfalls
Part of [[Power-Ups, Pickups and Unlockables]]. Prev: [[6. Worked Example Power-Up Playground]].
## Code pitfalls
| Symptom | Cause | Fix |
|---|---|---|
| Speed stays boosted after the power-up ends | Modifiers added with a different `Source` than the one removed, or the controller was destroyed before `End` | Always use the `ActivePowerUp` object as the source; `OnDisable → EndAll` (part 3) |
| Invulnerability ends early when two overlap | A `bool` flag instead of a reference count | Use `PowerUpController.Has`, which counts per activation |
| Power-ups drain while paused | `useUnscaledTime` on, or your pause does not set `Time.timeScale = 0` | Keep scaled time, or gate the tick on your pause state |
| Power-ups last "less" in combat | Hit-stop scales time down ([[Combat Feel and Hit Feedback]]) | Accept it, or tick power-ups on unscaled time during hit-stop only |
| Magnet does nothing | Query ignores triggers | `QueryTriggerInteraction.Collide` (3D) / `ContactFilter2D.useTriggers = true` (2D); check `pickupLayers` |
| Two gems count as one | Duplicated GameObject copied the GUID | Run **Fix Duplicate Collectible IDs** (part 4); never regenerate IDs in `OnValidate` |
| Gems reappear after an update | You renamed a scene (the default level ID) or edited IDs | Treat IDs and scene names as save data; use `levelIdOverride` before renaming scenes |
| "Unlocked!" toast missing | `UnlockService` enabled after the toast subscribed, or the event fired during a scene load | Keep both on the bootstrap object; service has an earlier execution order |
| Validator throws obsolete warnings | Old `FindObjectsByType(..., FindObjectsSortMode)` overloads | Deprecated in 6000.5; use `FindObjectsByType<T>(FindObjectsInactive.Include)` |
| Progress lost after a crash | Writing straight over the save file | Temp file + `File.Replace` (part 4) |
## Design pitfalls (Level Up! lens)
- **Reward inflation.** If every room has a power-up, none of them are special. Rogers: *the best rewards are hard won*. Budget power-ups per level in the beat chart (part 1) and check the economy report from [[4. Economy Tuning Sheets and CSV Import]].
- **Unreadable stacks.** Speed + double jump + magnet at once makes the controls feel different every few seconds. Use exclusive groups and keep simultaneous power-ups to two.
- **Hidden core goals.** Hidden unlocks are fun for secrets, frustrating for the main progression. If players need it to finish, show it.
- **Grind unlocks.** "Collect 10,000 coins" measures time, not skill. Prefer effort-based conditions (all gems in a level, a no-damage clear).
- **Punishing loss.** Losing collected souvenirs on death punishes exploration. The ledger keeps them by design (*How to Win at Losing*).
- **Power-ups that trivialise a hazard you just taught.** Introduce the hazard first, then the counter (part 1, 1.4).
## Security and cheating (offline single-player)
The progress file is plain JSON. A student can edit it and unlock everything. For a classroom or single-player game, that is fine and even educational. If unlocks gate anything shared (leaderboards), move authority to a server ([[Cloud Save and Unity Services]]) instead of obfuscating the file.
## Testing checklist
- Edit-mode tests for `PowerUpController` stacking rules and `UnlockService` evaluation chains ([[Unity Test Framework]]). Both are plain logic and easy to test with `new GameObject().AddComponent<...>()`.
- Run the collectible validator in CI on every scene in the build list ([[Build Automation and CI]]).
- Playtest with the debug keys off; designers forget how long 8 seconds feels without them.
## Sources
- `Object.FindObjectsByType` deprecation of sort-mode overloads (6000.5): https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Object.FindObjectsByType.html
- *Level Up!* Level 13, summarised in [[Level Up! (Review)]]