I have a main menu which calls this code to launch level 1 (using a collection proxy):
function on_message(self, message_id, message, sender)
if message_id == hash("load_level") then
print("LOAD LEVEL")
msg.post(message.proxy, "load")
...
After the player dies they may wish to restart the level.
Restart should (presumably) unload the collection object, then call that load_level code again (above).
For unloading the collection I have:
function on_message(self, message_id, message, sender)
...
elseif message_id == hash("clear_level") then
print("CLEAR LEVEL")
msg.post(message.proxy, "disable")
msg.post(message.proxy, "final")
msg.post(message.proxy, "unload")
...
But when I call this code:
-- Restart level:
msg.post("main:/game#levelProxies", "clear_level", { proxy = "/game#level1Proxy" })
msg.post("main:/game#levelProxies", "load_level", { proxy = "/game#level1Proxy" })
I get the following output:
DEBUG:SCRIPT: CLEAR LEVEL
DEBUG:SCRIPT: LOAD LEVEL
ERROR:GAMEOBJECT: The collection 'level1' could not be created since there is already a socket with the same name.
ERROR:GAMEOBJECT: AcquireResources NewCollection RESULT_OUT_OF_RESOURCES
WARNING:RESOURCE: Unable to create resource: /levels/level1/level1.collectionc: OUT_OF_RESOURCES
ERROR:GAMESYS: The collection /levels/level1/level1.collectionc could not be loaded.
I assume this means I’m unloading the object/proxy wrong. Can someone please tell me what I’m doing incorrectly?
Thanks!