Parent-child relationships

An entity with the ConnectedEntity component does not cause an entity to attach itself to the connected entity. It is on the game developer to detect entities with ConnectedEntity components and attach to them to their game specific parents.

Example

A ball that is supposed to be attached to the hand bone of a networked entity. In this case, the ball would show up only once the entity its connected to show up. To attach the ball to the hand, the game developer can write the following code snippet -

var entity = coherenceSync.LinkedEntity;
if (entity != Entity.Null && EntityManager.HasComponent<ConnectedEntity>(entity))
{
    var connected = EntityManager.GetComponent<ConnectedEntity>(entity);
    var parent = CoherenceMonoBridge.EntityIdToTransform(connected.Value);
    var hand = parent.Find("RHand")
    gameObject.SetParent(hand);
}

Last updated