Can I change gameobject url?

Greetings everyone! I need to spawn player with factory and rename him, because when it spawns it’s name is instance01.

I think you cannot and you should organize your code to work with the name you get returned by factory.create (or collectionfactory.create).

But, I may missing something…


@roccosaienz is correct. You cannot change this.

Then, can i change object id?

how do you do it currently?

self.player = factory.create(...)

self.player is now your global player id that you can use for everything. Is this what you want?

The question is why you want to change it?

Because i need to send messages to player from gui for moving him (i make game for mobile)

I think that Defold needs all url/id to be unique; this is the reason the engine prevents you to modify them.

There are many solutions to this problem. For example:

  1. the player spawner sends a message to the gui passing the url of the player
  2. the gui stores this somewhere in self, let’s say in self.player_url
  3. the gui uses this url to send messages to the player; something like, …)

I hope this helps.