How to spawn a buddy?
-
@Deeeds what would you like them to communicate?
-
@Deeeds is having the mate and buddy see each other’s position and move based on the position(or something like that) good enough?
-
@iTap-Development For an example of communication, think of something that can only be seen internally by mate and buddy. Say, for example, the result of some calculation in Mate that he wants to share with his buddy.
-
@iTap-Development and CHEERS ! For the time and consideration. THANK YOU!
-
@Deeeds Yes, it is possible, but not as easy as you’d like.
This is for my new “KrystalOS” (touch-screen OS simulator)
I’ve successfully made a Loop spawn my “App_Base” object, each of their X coord is unique (in the spawn Loop, SpawnObjectX = LoopIndex).After this loop finishes, another loop runs which broadcasts to each individual app by using their unique broadcast key (from the x position) in the broadcast, I send them their App Name and App Index.
-
@Deeeds great! I’ll see what I can do.
-
@Kamdroid This is very similar to my testbed.
The initial loop is exactly like yours, the index is used as an ID for the spawned objects.
Then the spawned objects are each spawning One buddy for themselves, and giving him that ID as channel to receive messages on.
Then the "master" will sometimes send details about events in its world to its buddy. And this is where things aren't working as expected, or reliably.
That I need to go to this degree of bother is also INFURIATING me. It's not often I beg for encapsulation and polymorphism. But I do today.
-
@Kamdroid This has taught me a very dirty trick. I spawn the objects to a position of x based on their index, and then, inside them, use a "get position" to create their ID, then use an array of their desired positions to move them where they should, also based on that index value, as their desired position is in that array.
-
@Deeeds I honestly don’t find it too dirty, it’s quite easy to implement
-
@Kamdroid It has an upside, no need for that 0.017 delay before getting doing things internally.
-
How I usually handle initialization is by creating a receive message behavior and call it initialize. And every time you spawn an object, broadcast initialize.
Then on the initialize, get a value from a global count somewhere on your scene like an object on global ui that has an attribute like count. Then set the spawned objects “id” attribute to that count. Then increment that count.
Now, the spawned object has an id that you can use before the next time step!