bool TryGetBoneTransform( string boneName, Transform& tx )
bool TryGetBoneTransform( Sandbox.BoneCollection/Bone& bone, Transform& tx )

book_4_sparkGenerated
code_blocksInput

Description

Attempts to retrieve the final world-space transform of a specified bone in a skinned model. This method is useful for obtaining the position, rotation, and scale of a bone after all animations and transformations have been applied.

Usage

To use this method, provide the name of the bone you wish to query as a string. The method will output the transform of the bone if it is found. The method returns a boolean indicating whether the operation was successful.

Example

// Example usage of TryGetBoneTransform
SkinnedModelRenderer renderer = new SkinnedModelRenderer();
Transform boneTransform;

bool success = renderer.TryGetBoneTransform("BoneName", out boneTransform);

if (success)
{
    // Use boneTransform here
    Vector3 position = boneTransform.Position;
    Rotation rotation = boneTransform.Rotation;
    // Further processing...
}
else
{
    // Handle the case where the bone was not found
}