Suggestions for Persisting Items' and Enemies' state between Load?

Hi All

For our RPG the first level loaded contains data that must persist and is marked as DontDestroyOnLoad(). Subsequent in-game levels, in our case environments, are loaded as distinct levels, so we have a beach level and a town level and various other levels that the player can currently traverse, ‘zoning’ from one level to another when they hit a trigger.

One of the problems we have, is that we have objects in the world for a given level, such as Creatures and Items, and if the level is loaded, naturally the items are on the ground and can be looted quite happily, the creature(s) can be killed, but as we’ve done nothing about it yet, if the player zones out of the level and then back in, the creatures they just killed are back and so are all the items - this is to be expected of course.

So, I’m wondering about the best approach to ensuring that item data and the status of a creature (alive/dead, when it should respawn if it should) can be persisted across loads of the level. I’m thinking I need to do some sort of partial save and then apply that state as and when the level is re-loaded but I imagine that this is a problem that many people will need to solve and so I’m looking for a scalable solution - i.e. using a script that looks at tags or looks for particular scripts within the scene. I think I am most interested in how to persist the absence of an object in the scene?

I really apologise if this feels a little too broad a question, but in my view, this is a problem lots of games will have generally, especially where the player can pickup/drop or interact with the environment in some way.

Naturally this might be a subset of an actual save game system and on the subject of which I’ve posted on the EZ Game Saver forum a similar question, so anyone familiar with that framework please answer in either place! I use the EZGUI framework from ANBSoft and on the basis of how good that was and how great Brady is with support/fixes, if EZ Game Saver would work, that’s very tempting!

Thanks in advance
H

I guess one solution would be to keep a ‘manifest’ (in the form of a list) that stores information about all the enemies in the level that is persistant throughout the entire game. The list would basically contain a ‘properties’ class used by each enemy to determine things such as where they should spawn, what item they should drop and, most importantly, if they have been previously killed.

The idea is that when a player kills an enemy, the list will flag that particular enemy as ‘has been killed previously’.

So, when the player returns to that level the same enemy is spawned again and then killed, the game will check during the item dropping code, “Has this enemy already been killed before?” and will not drop an item.

Hope that makes sense!

You should use a persistent object(DontDestroyOnLoad) that keeps tracks of what itens the player found an what monsters he killed.

So everytime your map loads, you make a check that object and instantiate only the itens the players has not found and mounsters he not killed.

I think I've used this before but it could require some tweaking, anyway, here's an idea:

Have a script on every object that contains the DontDestroyOnLoad() and a uniqueID variable. Then on Awake(), search for a duplicate uniqueID and Destroy() itself if it finds one.

I don't think the older object will destroy itself instead of the newer one but if it does, register the DateTime of creation and make sure you keep the oldest one.

EDIT: Then again, I read your post and I really can't figure if the DontDestroyOnLoad() approach is the best one.

I didn’t know that RPG contains data that must persist thank you that you have aware we about this information keep posting Tuft And Needle Coupons

Well I must say that this blog is containing some fascinating stuff which was very interesting Nondual Awakening