docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetOrCreateOn

    GetOrCreateOn(GameObject, bool)

    Retrieves the Trajectory component attached to a given game object, creating it if necessary.

    Declaration
    public static Trajectory GetOrCreateOn(GameObject gameObject, bool initializePoses = false)
    Parameters
    Type Name Description
    GameObject gameObject

    The game object to retrieve the Trajectory from.

    bool initializePoses

    Whether to initialize the poses of a newly created trajectory.

    Returns
    Type Description
    Trajectory

    The retrieved Trajectory.

    Remarks

    A Trajectory's poses get initialized automatically at the end of Update. If for some reason, a trajectory gets created after Update (e.g. during LateUpdate), set initializePoses to true to initialize the poses right after creation. Note that passing true for a trajectory created during Update could lead to wrong results, as game objects may be moved during Update. initializePoses has no effect if the trajectory already exists.

    In This Article
    Back to top
    Copyright © 2024 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)