Force load resource or clone object

Force load resource or clone object

So I’m using Creator but I think this is more a JS problem, although I’m actually using TS.

So I have json files which hold my stats and info about units. They basically make units. And I load one in using
and this was working fine, however it seems to cache the asset. So when I try and load multiple of them they all get the same object, so ones HP goes to 0 every unit of the same type goes to 0. Is there a way to force unique load each time so I get a unique object each time? Or an easy way to clone the data, I’ve done searches and it seems there is no solid way to clone in TS/JS. I really don’t want to have to write code to handle and manually copy each field again and again and again. Its boring, brittle and defeats the purpose of using a language that just makes objects from JSON.


Implement cloning


That’s the stuff I found, the problem is they set off my alarm bells. None actually do a clone, and each one has a “it works but doesn’t do this or that” and they are all different. The deep copy ones is probably what I need to be safe, but being a external function and not “part of the language” gives me concern that it might miss something. However a “load this file, no really just load it again” would guarantee to get everything new, entire contents with no caveats.