Hi all, trying to wrap my head around something.
I have a many images for enemies in my game. I need to select which one to show for an enemy at runtime and set it on a sprite. I have read that collection proxies should be the way to go.
For each enemy image, I have created an atlas that contains just the single image, and a collection with a sprite component set to the enemy image. I call these ‘proxy_<insert_enemy_name>.collection’.
In my game world, I then have a collection factory which spawns instances of ‘battle_character.collection’.
The ‘battle_character.collection’ has some scripts and sprites and a collection proxy for each of the possible enemy images. Each collection proxy has a different id and is assigned the relevant ‘proxy_<insert_enemy_name>.collection’.
When I run the game, I spawn instances of ‘battle_character.collection’ and once spawned, I send a message to the new instance telling it which proxy collection to load. If I use msg.post("#proxy_<insert_enemy_name>", “load”) from within ‘battle_character.collection’ I get a warning:
WARNING:GAMEOBJECT: Instance is initialized twice, this may lead to undefined behaviour
… and the image does not appear.
If I try and use “async_load” I get an error stating that the socket is already in use.
I do listen to the “loaded” message and then “init” and “enable” the proxy, but no luck actually seeing anything. I see that the sender has a unique url each time, so I don’t understand the warning either - nothing should be initialized twice?
So, my question is, is the warning wrong? And should this work? How else can I set this up? I really don’t want to use gui nodes to dynamically load the images if I can help it.