I am dynamically loading objects using a custom DropListener and a listenForDrops event. I am getting the drop events and loading objects succesfully.
I am adding the Deleteable, DragControls and SyncedTransform components to try to make the loaded objects behave like the objects in the sandbox sample.
The Deleteable and DragControls components seem to work as expected, but the SyncedTransform component does not.
The objects only get added to the instance where they were dragged in from.
Is there a specific way to add networked synched objects, or something I need to do to add a SyncedTransform and get my object to show up in all instances?
listenForDrops(evt : any)
{
// clear all children, re-add the new one
var gltf : GLTF = evt.detail;
console.log("Got a DROP EVT: " + gltf.scene.name);
this.gameObject.clear();
GameObject.addNewComponent(gltf.scene, Deletable)
GameObject.addNewComponent(gltf.scene, SyncedTransform)
GameObject.addNewComponent(gltf.scene, DragControls)
this.gameObject.add(gltf.scene);
}
It doesnt work because you need to synchronize the guid between the synced transform components that you add between all clients.
The original filespawn has a seed that gets synchronized between all clients. We previously had a code path that added SyncedTransform components etc based on that seed - that code path is currently disabled tho. But you could use e.g. the name + bytesize of the dropped object to generate a somewhat stable seed between all clients and then set the guid of the components using a UIDProvider.
You can look at the code in engine_networking_files_default_components.ts for an example which is the code path i metioned that is currently disabled
I should ask… what is the ‘backend url’ member of the dopr listener? Do i need to implement a function that handles drops and sends the file to other clients or something?