Ok I'm having two related issues here. I have a prefab with this authoring component on it:
public struct CrewMemberStub : ICleanupComponentData {
[GhostField]
public int LocalPlayerId;
}
[DisallowMultipleComponent]
public class CrewMemberAuthoring : MonoBehaviour
{
class Baker : Baker<CrewMemberAuthoring>
{
public override void Bake(CrewMemberAuthoring authoring) {
DependsOn(authoring.GetComponent<Rigidbody>());
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent<CrewMember>(entity);
AddComponent<CrewMemberStub>(entity);
}
}
}```
The prefab also has the "Ghost Authoring Component" on it, set to "Owner Predicted" as the default ghost mode.
Then I have this code in a server side system to spawn this object:
```cs
Entity player = commandBuffer.Instantiate(prefab);
commandBuffer.SetComponent(player, new GhostOwner {
NetworkId = networkId.Value
});
commandBuffer.AddComponent(player, new CrewMemberStub {
LocalPlayerId = requestComponent.ValueRO.LocalPlayerId
});
commandBuffer.AppendToBuffer(reqSrc.ValueRO.SourceConnection, new LinkedEntityGroup {
Value = player
});
commandBuffer.DestroyEntity(reqEntity);```
My first issue is:
- Why does this work with AddComponent instead of SetComponent for my CrewMemberStub? With SetComponent I get a System.ArgumentException here. But AddComponent workd.
And probably related, the second issue is that the entity does spawn in both the server world and the client world, but the client world entity doesn't have the CrewMemberStub component at all. It's only there in the server world.
What am I missing, and/or what further info should I share to help debug this problem?