top of page

The Penguin Queen's Odyssey DevLog #2: Scene Persistence

Mattia Poggi
Dec 2, 2024
2 min read

In this DevLog, I want to delve into an essential part of The Penguin Queen’s Odyssey: implementing scene persistence and retaining the player’s score across different levels. While this feature might seem small, it plays a crucial role in maintaining immersion and ensuring a smooth gameplay experience.



🏰 Why Scene Persistence Matters


As players guide Neferusobek through her epic journey to reclaim her throne, they encounter numerous challenges and enemies. Each level builds on the last, and keeping track of the player’s progress—including their score—adds to the sense of continuity and achievement. Without scene persistence, players would lose their progress every time they moved to a new level, which would break immersion and disrupt the flow of the story.


🛠️ Implementing Scene Persistence


To keep the game state consistent across scenes, I focused on a few key elements:


  1. Persistent Game Manager: I created a Game Manager object that persists throughout the game’s lifecycle. By marking it as DontDestroyOnLoad, the Game Manager carries the player's data across scenes, ensuring continuity. This object tracks the player’s score, lives, and other critical variables, allowing the game to pick up right where it left off when a new level loads.


  2. Scene-to-Scene Data Handling: When transitioning between scenes, the Game Manager ensures that essential data, like the player’s score, isn’t reset. Each new scene references the Game Manager to retrieve the current score and update the UI accordingly.


  3. UI Synchronization: Keeping the score display in sync across levels required ensuring the UI fetched the correct values from the Game Manager whenever a new scene started. This ensured that players always had an accurate view of their progress.


🚧 Challenges and Lessons Learned


One tricky aspect was ensuring that data didn’t get reset unintentionally when transitioning between scenes. Early on, I noticed occasional inconsistencies where the score would revert to zero. Debugging revealed that I needed to carefully control how and when the Game Manager passed data to avoid overwriting it during transitions.


Another challenge was ensuring that the Game Manager didn’t duplicate itself. By checking for an existing instance and destroying any duplicates, I maintained a single source of truth for the game’s data.


🚀 Looking Ahead


Implementing scene persistence taught me a lot about managing game state and enhancing player experience. In future updates, I’d love to expand this system to include more complex data. The Penguin Queen’s Odyssey is a project close to my heart, and tackling these technical challenges has been a rewarding part of bringing its magical world to life.


Have you faced similar challenges with scene persistence or data management in your projects? Let’s share insights and keep learning together! 🐧✨

Comments


Made by Mattia Poggi, 2024. Powered by Wix

bottom of page