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

book_4_sparkGenerated
code_blocksInput

Description

The TryGetBoneTransformAnimation method attempts to retrieve the world-space transform of a specified bone after animation processing but before any physics or procedural bone modifications are applied. This method is useful for obtaining the animated position and orientation of a bone at a specific point in the animation pipeline.

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 world-space 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.GetBone("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
}