Hi there, hello!
Does anyone know a way to control the rotation of a child entity of a ghost entity over the network?
On the Ghost Authoring Component of the root entity, I enabled Ghost Group, and then used the line below to try link the entity with the ghost entity, but when I test, the entities disappear.
if (!tag.RanFirstTime)
{
ECB.AppendToBuffer(sortKey, parentTank.Value, new GhostGroup { Value = entity });
tag.RanFirstTime = true;
}
Child entities (1s level hierarchy only) aren’t synched by default.
In order to replicate rotation and translation for a child entity you need:
Bake the child entity transform. By default, the Entities package does not bake any LocalTransform for child entities. It is necessary to add at least one baker that do a `GetEntity(TransformUsageFlag.Dynamic) for that to occur.
Once you have the LocalTransform baked, you can add a GhostAuthoringComponentInspector authoring component (from Netcode Package) that let you customize and set the replication behavior for the various entity components. In particular, you can setup the Variant use to serialize the transform.
You can set in the Variant selector the variant to use (for example Translation3D) and that will start replicating both rotation and translation (also scale) for the child entity.
Hi, thanks for the response.
I’m making a Tanks game that supports single player and multiplayer modes, and here’s my Tank prefab’s hierarchy setup:
Root Tank(With the tank controller's authoring components and Ghost Authoring Component)
|
|-->Tank body(With a mesh renderer only)
| |
| |--> Tank Turret(With the tank turret controller authoring, baker)
|
|-> Tank Tires(With a tire authoring component)
I have already made the single player mechanics system to use this setup, now I want the multiplayer system to adopt it as well.
I guess, I’ll have to restructure it and rewrite my systems logic as well to explore the route you suggested, but is there really no other way to get around this?