How to detect and transfer Mesh, Materials etc. across network #8815
-
Hi again. ContextI am in the process of serializing data across network with my plugin. I have entities and components covered by now so I am moving on to asset types. This includes Mesh, Materials, and all other assets either created programmatically or imported from the asset folder. I noticed that when I sync the Handle component between clients it automatically gets replicated with an already filled reference to the same asset id or asset path id. So in theory all I need to do is a plugin that keeps assets in sync directly from memory, and clients would just be able to reference the same id. This assumes that asset ids are deterministic, and/or I can create an asset with a specified id on clients. Also StandardMaterial is Reflect and that is okay, but for example Mesh is not even Reflect. QuestionWhat is the intended way from the engine authors to handle these types for these situations? And to be able essentially to create a custom asset manager? Mesh & StandardMaterial are not components either, but assets used from Handle components. How to detect their change, eg if they get reloaded from disk, since they won't be part of the ECS essentially, I assume I cannot just query them? Is there another plugin I have to hook into in order to know when these are newly added or changed, or deleted? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Is by any chance |
Beta Was this translation helpful? Give feedback.
-
I am trying to advance on this currently. Right now I am at the stage of creating a test setting up bevy for a minimal + assets enabled. However it seems that How to setup a MinimalPlugins configuration that will also have Assets enabled? |
Beta Was this translation helpful? Give feedback.
-
Can anybody help here, in how to setup a MinimalPlugin with assets (mesh, materials) available? |
Beta Was this translation helpful? Give feedback.
-
What do you mean by "sync asset ID between clients"
Do you mean several entities in the same Are you asking how to extend this to multiple processes or multiple devices? This is not how assets are supposed to work. I don't understand what you mean. How to create your own asset handling?You would implement your own How to add assets to a
|
Beta Was this translation helpful? Give feedback.
-
I'm writing a network plugin aimed at collaborative editing to keep things in sync across different clients. Actions in one client will be propagated across all the others. Since I've covered components for now, So now I have to address actual assets transfer through the network In order to develop things right, I am creating automated tests that will check this behavior and in doing so I am setting up bevy with minimal plugins (because headless, for automation). While adding While my original question is about Assets, and it still keeps being so, I am also starting to worry about how bevy will address these test environments situations, that is, test setups that are not exclusively minimal. I'm pretty sure at some point these will surface themselves too. |
Beta Was this translation helpful? Give feedback.
-
After some lenghty trial, I ended up with this setup to have a StandardMaterial in a test environment: app.add_plugins(MinimalPlugins);
app.add_plugin(AssetPlugin::default());
app.add_asset::<Shader>().add_debug_asset::<Shader>();
app.add_plugin(PbrPlugin::default()); I think I can continue with my work for now, I will close this question and go with the AssetPlugin solution with this modification. |
Beta Was this translation helpful? Give feedback.
What do you mean by "sync asset ID between clients"
Do you mean several entities in the same
World
as in: within a single process? (eg: you lauched the game once by running the compiled the binary)Are you asking how to extend this to multiple processes or multiple devices? This is not how assets are supposed to work. I don't understand what you mean.
How to create your own asset handling?
You would implement your own
AssetIo
. For example, for WASM, bevy has a different, http-based,AssetIo
implementation. WithAssetIo
y…