Documentation

Unity Engine


Unity Engine


SetParent(Entity, Entity, bool)

Establish a new link between a child and parent entity.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule
public void SetParent(Entity child, Entity newParent, bool preserveWorldTransform = true)

Parameters

child

The entity whose parent should be changed.

newParent

The new parent entity for
child
. If this value is Entity.Null,
child
will have no parent and will become the root of a new hierarchy.

preserveWorldTransform

If true, the world-space transform of
child
will be preserved as closely as possible by setting its LocalTransform component to match its current world-space transform. Slight differences are still possible due to floating-point rounding.
If false,
child
's LocalTransform components will not be modified. However, the existing value will now be relative to world-space instead to its previous parent; this may cause a significant instantaneous change in its world-space transform.

Remarks

This function must not be used from an ExclusiveEntityTransaction context. Manipulating transform hierarchies from worker threads is not safe.