Skip to content

Hierarchy and Transforms

↑

The Hierarchy shows the objects in the loaded scenes. A parent-child relationship makes child transforms relative to the parent. transform.position is in world coordinates; transform.localPosition is relative to its parent. Rotations follow a similar distinction. A nested child inherits the parent’s movement and rotation, and often scale, which can create surprising physics behavior.

Group related objects under deliberate parents (for example Player > Model > WeaponMount), but avoid huge deeply nested hierarchies just for visual tidiness.

FollowParent.cs
using UnityEngine;
public sealed class FollowParent : MonoBehaviour
{
[SerializeField] private Transform target;
private void LateUpdate()
{
if (target == null) return;
transform.position = target.position + Vector3.up * 2f;
}
}

Why LateUpdate? It runs after normal Update methods, making it suitable for many follow-camera adjustments. Pitfall: Calling SetParent(parent, false) keeps local transform coordinates; SetParent(parent, true) attempts to preserve world space.

Try it: Parent a cube under a rotated object and compare position with localPosition in the Inspector and Debug.Log.