bool TryGetBoneTransformAnimation( Sandbox.BoneCollection/Bone& bone, Transform& tx )

robot_2Generated
code_blocksInput

Description

The TryGetBoneTransformAnimation method attempts to retrieve the worldspace transform of a specified bone after animation processing but before any physics or procedural bone modifications are applied. This can be useful for understanding the position and orientation of bones immediately after animation calculations.

Usage

To use this method, you need to pass a reference to a Bone object and an uninitialized Transform object. The method will attempt to populate the Transform with the bone's worldspace transform. The method returns a boolean indicating whether the operation was successful.

Example

// Example usage of TryGetBoneTransformAnimation
SkinnedModelRenderer renderer = new SkinnedModelRenderer();
BoneCollection.Bone bone = renderer.GetBoneObject("BoneName");
Transform boneTransform;

bool success = renderer.TryGetBoneTransformAnimation(ref bone, out boneTransform);

if (success)
{
    // Use boneTransform here
    // For example, print the position
    Vector3 position = boneTransform.Position;
    // Do something with the position
}
else
{
    // Handle the case where the transform could not be retrieved
}