#How to synchronize child entity over the network
1 messages · Page 1 of 1 (latest)
bump...
still waiting for help on this...
it's been a year since i've touched netcode, but don't you just toggle on ghost group on the ghost?
[Tooltip("Add a `GhostGroup` component, which makes it possible for this entity to be the root of a 'Ghost Group'.\n\nA 'Ghost Group' is a collection of ghosts who must always be replicated in the same snapshot, which is useful (for example) when trying to keep an item like a weapon in sync with the player carrying it.\n\nTo use this feature, you must add the target ghost entity to this `GhostGroup` buffer at runtime (e.g. when the weapon is first picked up by the player).\n\n<i>Note that GhostGroups slow down serialization, as they force entity chunk random-access. Therefore, prefer other solutions.</i>")]
public bool GhostGroup```
I found out about GhostGroup component, and I tried using an ECB's AppendToBuffer function to connect the child to the parent ghost, but when I try that, and build to test, the Entities become invisible
so you added it to the ghostgroup buffer?
It isn't an IEnableableComponent. Its a DynamicBufferComponent
yes
by toggle on, i mean't in inspector
Yes, I enabled it on the GhostAuthoringComponent.
Replicating components on children is simpler than that: Add a GhostAuthoringInspectionComponent to the child, and change the Variant for said component to the RotationOnly (in EntitiesSamples > NetcodeSamples IIRC) replicated one.
GhostGroups are to ensure 2+ actual ghost entities are replicated together (i.e. added into a single snapshot). Useful for stuff like:
- Player ghost holding a Shotgun ghost.
Thanks!
I will try that.
Hi @main estuary
The component is not editable.
BTW, which scene/prefab should I look at on the NetcodeSamples project to see how it was done?
Try edit the prefab not instance
Its a child of the prefab
This green box implies you're trying to make a prefab modification outside of the prefab. I.e. You're not modifying the core prefab itself, you're adding the InspectionComponent as a scene-specific override. This is not supported, you need to open the prefab directly.
Note: We've also seen issues with how we validate whether or not the GhostAuthoring is writeable. It was too strict in 1.1, then too weak in 1.2. Working on making it clearer, thanks for the feedback!
I see, I was editing the prefab variant. Because the game has both single player and multiplayer modes so I imagined that to achieve a faster iteration time when making changes to the game in the future it'd be better if I used a prefab variant on the Netcode connection thereby allowing me to modify the original(singleplayer) prefab and have its changes be propagated into the multiplayer variant.
It worked!
Been busy for the past week and kept working on the single player mode that I forgot to try this when I got home. But I just did and it worked!
I wish it worked on a prefab variant though.
Wondering if I'm having a similar issue or my issue is something else. Have a netcode project, have some characters using ThirdPersonCharacterControllers from the samples, and Rukhanka for animators.
Problem i'm having is the Animator Parameters seem to be replicated to the ServerWorld and i can see them updating in the ENtity Inspector, but not in the ClientWorld
my prefab has the Ghost Authoring component on it which i think is right because it has to be on the root prefab, and then the character is a child that has the Animator on it and that is a "prefab variant" of the fbx with the animations. I tried putting the Ghost Authoring Inspection COmponent on the child object that has the Animator, but still it doesn't seem to be replicating the AnimatorParameters to other clients
Apologies for bumping a pretty old thread here, but I haven't been able to replicate the behavior described here #1233043775148785714 message. I did read elsewhere that child transform replication only works as far as the first hierarchy level, but I have also heard that that's no longer the case since 1.0. Any confirmation on that?
I'm trying to position a weapon in the hands of a character running in PredictedSimulationSystemGroup. The character is struct contains a reference to an entity positioned where I want the weapon, which it populates with GetEntity in the character's authoring.
I can successfully position the weapon by setting the weapon to the LocalToWorld position and rotation of the target positon, but I cannot set it to the transform of the target; the game will simply behave as if that transform was at world origin. The LocalToWorld is unfortunately jittery, so I kind of need to get at that localtransform somehow.
Update: was barking up the wrong tree, trying to extract a world position from LocalTransform. I see what I need to do involves ComputeWorldTransformMatrix (https://docs.unity3d.com/Packages/com.unity.entities@1.2/api/Unity.Transforms.TransformHelpers.ComputeWorldTransformMatrix.html). Since figuring this out I've got it close to working, but there is still some movement jutter that isn't present if I just set the weapon transform to the character root transform
Aaaand got it. Had to run in [UpdateInGroup(typeof(TransformSystemGroup))] rather than predicted simulation group
For people from the future trying to synchronize positions with children of ghosts: There is no way to global position from a LocalTransform directly, and LocalToWorld components are not kept up to date accurately during all phases of the life cycle. See the above link for details.