Need help using collection proxies

Hello

I am trying to load a collection using:
msg.post("/Loader#Game Over", "load")
but when the game runs the code I get this error:
ERROR:GAMESYS: The collection /assets/Collections/Game Over.collectionc could not be loaded since it was already. Message 'load' sent from main:/endscreen#endscreen to main:/Loader#Game Over.
Any idea what I am doing wrong here?

I have the collection proxy named “Game Over” under one game object and it is trying to load a collection with only one game object in it.

The error message is pretty clear. You are trying to load a collection that had already been loaded. To have a problem with three logic in your code.

Have you looked at the collection proxy example?

I have looked at the collection proxy manual, and did what it said to do.

The problem is that if I try unloading it and then loading it, I get an error message telling the that the collection has to be loaded before it can be unloaded.

Share your code and a screenshot of how the collections are set up. Have you checked the proxy example? It’s a minimal amount of code and works.

The proxy example is functional, but maybe a little confusing at first. This is my own loader script I made which handles all collection proxy loading/unloading.

-------------
-- Helpers --
-------------

local show_proxy

function show_proxy(self, proxy)
        -- If a proxy is loaded already, unload it
	if self.current_proxy then
		msg.post(self.current_proxy, "unload")
	end
        -- Load the requested proxy
	msg.post(proxy, "async_load")
end

-----------------
-- End Helpers --
-----------------

----------------------
-- Defold functions --
----------------------

function init(self)
	msg.post(".", "acquire_input_focus")
        -- Load the first proxy of the game. Usually a main menu or loading splash screen
	show_proxy(self, "#first_proxy_you_want_player_to_see_when_starting_the_game")
end

function on_message(self, message_id, message, sender)
        -- When you send a message to load a proxy, it will send a message back to you  once it is successfully loaded with the message_id of hash("proxy_loaded")
        -- You can go ahead and set the self.current_proxy to track the newly loaded proxy, and enable it, running the init() of all of the game objects, gui objects, etc.
	if message_id == hash("proxy_loaded") then
		self.current_proxy = sender
		msg.post(sender, "enable")
	elseif message_id == hash("switch_proxy") then
		show_proxy(self, message.switch_to)
	end
end

--------------------------
-- End Defold functions --
--------------------------

Then your main.collection can look like this Annotation%202019-08-04%20092437

Switching to a proxy is then done like so

msg.post("main:/loader#loader", "switch_proxy", { switch_to = "#world_proxy" })
1 Like