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
The entity whose parent should be changed.
The new parent entity for . If this value is Entity.Null, will have no parent and will become the root of a new hierarchy.
childchildIf true, the world-space transform of 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.
childIf false, '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.
childRemarks
This function must not be used from an ExclusiveEntityTransaction context. Manipulating transform hierarchies from worker threads is not safe.