Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Customizable 3D character component(s?)

Discussion in 'Graphics for ECS' started by Devkatt, Jul 11, 2023.

  1. Devkatt

    Devkatt

    Joined:
    Jul 10, 2023
    Posts:
    1
    I am new to Unity and wonder what is the ECS/DOTS way to customize a 3d mesh?

    By customize I mean for example offer a wardrobe, let the user chose clothes to put on the character. How would that work in a ECS? Lets say that every clothes is a 3D mesh, I must somehow store these clothes in a component. There must be a head slot, body slot, legs slot and so on. What data type should these slots be?

    Or should I make one component for every clothes and then "tag" these on the character? So a character is essentially a base model component, head component, body component, leg component and so on. How would I get all this to follow the character as it moves?

    Do anyone have a good sample code for this? I cannot find anything useful from my search terms.

    EDIT: I _think_ that I am wanting something like in this example: https://github.com/DapperDino/Multiplayer-Character-Select/tree/main but for DOTS.

    UPDATE: Okay I think I grasped the basic concepts. In this post https://forum.unity.com/threads/how-to-create-procedural-meshes-at-runtime.1436287/ they talk about Procedural Meshes, not really what I am trying to achieve. But, what is interesting here is that you can generate a mesh in ECS, maybe I can use it to load a mesh and append it on my character somehow! This is also a good place for mesh generation: https://github.com/Dreaming381/Latios-Framework-Documentation/blob/main/Kinemation Animation and Rendering/Dynamic Meshes.md

    Here is how you can "Weakly reference an object" https://docs.unity3d.com/Packages/c.../content-management-get-a-weak-reference.html Hmm... And here is how you can "Load a weakly-referenced object at runtime" Hmmmm..... Whats interesting about this that I could store a mesh in an Component. So if I have a number of hats, I could create a HatComponent and then change the hat via a
    WeakObjectReference<Mesh>

    This is far from a complete solution, I will keep on tinkering about how all of this can be put together.

    UPDATE2: Here is something called submesh! It appears needing ye olde GameObject through! https://github.com/Unity-Technologi...RPSamples/Assets/SampleScenes/6. Misc/Submesh
     
    Last edited: Jul 17, 2023