#Separating SharedComponents from similar entities

1 messages · Page 1 of 1 (latest)

hot plume
#

Hi everyone, I have a problem :

In Play Mode, I'm dynamically spawning entities (all from the same gameObject prefab), and when spawned I want to modify their body colour and the tool they are using (the entities are humanoid characters who can collect resources)

I have a script working fine, but the problem I'm having is it's modifying all already spawned characters too each time I modify a new spawned one (probably because it's a shared component), how to separate each entity from one another (by maybe setting a separate archetype chunk for each one of them, or another solution if it exists).
My entities don't have any RenderMeshUmanaged components or anything alike (probably because I'm using the Rukhanka - ECS Animation System asset to animate them, so the gameObject prefab's SkinnedMeshRenderer component is baked into a custom component related to that asset)

Here's my code :
https://paste.mod.gg/yklfxtcgpdoa/0

Thanks in advance!

whole kindle
#

Hi. No, Rukhanka just adds custom components to the baked SMR entity. Initial preparation (and submesh splitting) is a task of Entities.Graphics

hot plume
flint magnetBOT
whole kindle
#

Note that you need to work with submesh render entities, which is not the skinned mesh render entity.

hot plume
# whole kindle Your approach a bit wrong. In your code you are changing material property direc...

Hi there,

Thanks for your help, but it seems I missed something along the way using Material Overrides, as they are not working.

First Attempt: Unity Default Component

I tried using the Unity default component. After setting up my shader graph color parameter correctly (Hybrid per Instance) and applying it to my character's prefab child GameObject with a SkinnedMeshRenderer (in Edit Mode before conversion to ECS through the SubScene), it worked fine to modify the color of the character through the inspector. However, once converted, it becomes a default MaterialColor IComponentData, and changing it by code doesn't affect the color of the entity character.

Second Attempt: Custom Code

I then tried doing it entirely by code using this method. I created a custom IComponentData with the MaterialProperty attribute and, through a Baker script, added that component to the same entity with the Rendering component. I also updated its value with my system, but this didn't work either.

Here’s my code:

hot plume