# SetParent(Entity, Entity, bool)

> Establish a new link between a child and parent entity.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

```csharp
public void SetParent(Entity child, Entity newParent, bool preserveWorldTransform = true)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity whose parent should be changed.**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The new parent entity for `child`. If this value is [Entity.Null](/engine/7000.0/script-reference/unity/entities/entity/null.md), `child` will have no parent and will become the root of a new hierarchy.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): 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.
