Send message to spawned object

Apparently, this hasn’t been solved so I figured I would give it a go. This is how to send a message to the spawned object.

Put this in the object that spawns the other object (This messages ALL spawned objects)

Messages last spawned object

And this is what you put into the object you spawned


You’re welcome in advance everyone :llama:.
If you need any help with the code feel free to ask and I’ll help

(The Random behavior can be replaced with a thing that gets the numbers in your Object Name, but the problem with that is that you can’t name your objects)

When I say you can't name your objects for the second method this is what I mean

Screenshot 2022-04-29 10.23.50 AM

If you guys need an example for anything else you need to do ask and I’ll see what I can make for it.

Also, @chrisdakiller this is what I was saying.
@Samuel_PixelPizza does this help you?

grazer is also discussing possible solutions for this in the discord server as well, i should show him this topic

1 Like

Sure you could do that, also happy to help.
Another thing, the random behavior could probably be replaced with some sort of global so it guarantees a new value each time but I didn’t have the time to bother figuring it out.

This doesn’t help for sending messages from multiple of the same type to spawned objects of multiple of the same type. I tried this before with another system and had messages miss mailboxes for sending thousands of messages each frame.


wdym? It sends a value unique to each of the objects

Just only one spawner, having more than one spawner will be sending to several objects with the same ID. And this doesn’t seperate different spawn objects types.

1 Like

So it won’t register the value being sent because it’s receiving multiple at once. That makes sense, but it should be fine for around 30 objects (An object can output around 30 times a frame I think), right?

What do you mean by this? Each object has a unique object ID.
I’m great at coding, but I’m not sure what you’re saying. Can you phrase it differently?

You have no way to check for duplicate ID’s, and if you have several spawners, the chance of a duplicate ID is greater.

(as for the multiple at once, 30 may be fine but it will be multiplied for each spawner added)

1 Like

This should get rid of the chance for duplication right? Because each object gets a unique ID chosen by flowlab so it should never be the same

This ID would be the spawner, so all spawned objects would have the starting value of the spawner ID.

1 Like

Yes, is there a problem with this?

If you spawn more than 1 object from that spawner, they would all have the same ID…

1 Like

But the purpose is to message to ALL spawned objects. That’s mostly an excuse for my mind blanking. I’ll make a version for the last spawn object as well.

1 Like

That should give each spawned object a different value now.

It gives each a value, and works for last spawned object.
But mostly works as a trigger and not much for sending data to the object.

1 Like

To send data to the object just send a second message with the data. (In the screenshot on the top there is a Number behavior in the spawned object, set it to the data you wanted you send to the object at the time)

Sending a second message will go to all objects of the same type, you could maybe use the first message to turn on a switch to recieve it.

(I mean sending data from the spawner to the spawned object)

1 Like

Overall, an ID message system is not a bad idea and can work in many cases.
Just a complex structure with many different spawn types and spawners may get difficult.
And having too many messages being sent in a single frame may lose messages.

It’s a great method, just not the end all solutions for messaging spawned objects.

1 Like