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.