docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Transform concepts

    You can use the Unity.Transforms namespace to control the position, rotation, and scale of any entity in your project.

    The following components are used in the transform system:

    • LocalToWorld
    • LocalTransform
    • PostTransformMatrix
    • Parent
    • Child

    There are two systems that update the transform system:

    • ParentSystem
    • LocalToWorldSystem

    Transform hierarchy

    Unity.Transforms is hierarchical, which means that you can transform Entities based on their relationship to each other.

    For example, a car body can be the parent of its wheels. The wheels are children of the car body. When the car body moves, the wheels move with it. You can also move and rotate the wheels relative to the car body.

    An entity can have multiple children, but only one parent. Children can have their own child entities. These multiple levels of parent-child relationships form a transform hierarchy. The entity at the top of a hierarchy, without a parent, is the root.

    To declare a Transform hierarchy, you must do this from the bottom up. This means that you use Parent to declare an Entity's parent, rather than declare its children. If you want to declare a child of an Entity, find the Entities that you want to be children and set their parent to be the target Entity. For more information, see the Using a hierarchy documentation.

    The LocalToWorld component

    The LocalToWorld matrix represents the transform from local space to world space. This matrix is what the rendering system uses to render the entity's geometry. By default, the LocalToWorldSystem updates this component from the LocalToWorld component. This default update means that you don't need to update LocalToWorld, and the system does that for you. To disable this automatic update use a [WriteGroup(typeof(LocalToWorld))] attribute on a component. With this write group, you have complete control over LocalToWorld. For more information, see the documentation on write groups.

    Note

    The LocalToWorld component value might be out of date or invalid while the SimulationSystemGroup is running. This is because the transform system only updates the component value when the TransformSystemGroup runs. It might also contain additional offsets applied for graphical smoothing purposes. Therefore, while the LocalToWorld component might be useful as a fast approximation of an entity's world-space transformation when its latency is acceptable, you shouldn't rely on it if you need an accurate, up-to-date world transform for simulation purposes. In those cases, use the ComputeWorldTransformMatrix method.

    The LocalTransform component

    The LocalTransform component has three properties. They control the position, rotation, and scale of the entity. When this component is present, it controls LocalToWorld:

    public struct LocalTransform : IComponentData
    {
        public float3 Position;
        public float Scale;
        public quaternion Rotation;
    }
    

    If the entity has a Parent component, Position, Rotation, and Scale are relative to that parent. If the entity doesn't have a Parent component, the transform is relative to the origin of the world.

    The PostTransformMatrix component

    LocalTransform only supports uniform scale. To render geometry with nonuniform scale, you must use a PostTransformMatrix matrix. This is applied after LocalTransform. You can also use this component to introduce shear transforms, or to translate the entity relative to its pivot.

    The Parent component

    The Parent component defines the hierarchy. You put this on every child that you want to be part of a hierarchy.

    The Child component

    The Child component buffer holds all children of a parent. ParentSystem manages this buffer and its contents. You only need to manage the Parent component. The system will take care of maintaining the corresponding Child component.

    The ParentSystem

    The ParentSystem maintains the Child component buffer, based on the Parent component of the children. When you set a Parent component on a child, Unity only updates the parent's Child component when the ParentSystem has run.

    The LocalToWorldSystem

    LocalToWorldSystem computes and updates the LocalToWorld component, based on the LocalTransform component and the hierarchy. When you set a LocalTransform component on an entity, Unity only updates its LocalToWorld component when the LocalToWorldSystem has run.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Transform hierarchy
    • The LocalToWorld component
    • The LocalTransform component
    • The PostTransformMatrix component
    • The Parent component
    • The Child component
    • The ParentSystem
    • The LocalToWorldSystem
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)