Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: misterjuly on July 28, 2021, 11:50:15 AM
-
Hello,
I have a collectible you collect in scene 1 (it does disappear when I collect it). You then go through a door to scene 2. You then do something and go back to scene 1. However, the already collected collectible reappears even though I told it to destroy it once the player came in contact with it. How do I get the game to remember I have already collected it even when switching scenes? Thanks!
-
How are you loading scenes, additively or as a single scene?
-
Im not entirely sure what you mean. I use the load level action to load the level if that helps... I think there is only one scene loaded at a time. Hopefully that gives you more info on how to help me. Thanks!
-
When you are loading a new scene non-additively, the old scene is not being kept in memory, it's destroyed. If you load a new scene additively, old scene remains in memory. Of course, if you're not managing it properly, you'll fill up the memory and cause a crash.
So, either loading scenes additively with smart memory management (depends entirely on the game) or loading them single (but destroying the old scene) and using save system (player prefs, easy save, smooth save, whatevever) to store data what has been collected or not.
No third option i'm afraid.
-
So I have smooth save and I want to have the game remember that I collected the object without loading multiple scenes. Do I have the game object as a variable (if so how do I do that). Thanks!
-
I never used smooth save, but i suppose it works the same as playerprefs in that regard. Let's say you have a coin as a pickup. You set a prefs key for it, for example "Coin1PickedUp". It would be a bool, with a default value false. When you pick it up, you will write the value true to that prefs. Mext time you load a scene, before it's created, the coin will get the prefs and bool test it, if it's true, it will get destroyed (or not spawned if you use a spawner for it) if it's false, it will be created or it's renderer enabled or howevwr you want to organize it, but for performance i propose creating spawners instead of coins that will spawn the coins or not depending on the prefs.
If your game starts anew when you quit, reset thise prefs to default before quitting.
-
I think I figured it out. Thanks SO MUCH for your help!
-
Glad to help, shout if you get stuck somewhere, it can be a bit complicated sometimes.