docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Transform broadcasting example

    Review an example of publishing a transform hierarchy and subscribing to it on the /tf topic.

    Publish a transform hierarchy

    Attaching TfBroadcasterComponent to your robot's root GameObject in the scene is the only step required. The component publishes on /tf automatically, so no additional code is necessary. Refer to Publish your scene's transform hierarchy.

    Subscribe to a transform hierarchy

    To subscribe to /tf from another component, create a SubscriberBehaviour<TFMessageMsg>:

    using Unity.Simulation.Foundation;
    using Unity.Simulation.Foundation.Tf2Messages;
    using System;
    using UnityEngine;
    
    public class TfListener : SubscriberBehaviour<TFMessageMsg>
    {
        public override string DefaultTopic => "/tf";
    
        protected override Action<TFMessageMsg> Callback => msg =>
        {
            foreach (var transform in msg.transforms)
            {
                Debug.Log($"{transform.header.frame_id} -> {transform.child_frame_id}");
            }
        };
    }
    

    Additional resources

    • Publish your scene's transform hierarchy
    • Transform broadcasting reference
    In This Article
    Back to top
    Copyright © 2026 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)