Adding bone attachments

Beginner Getting started

If you would like to attach a model to a specific bone of an animated character, you can use method BBMOD_AnimationPlayer.get_node_transform. This takes an ID of a bone and returns its transformation in world space, which you can then use when rendering the bone attachment. The returned transformation is of BBMOD_DualQuaternion type, so you will need to first convert the dual quaternion to a matrix using its ToMatrix method. Bone IDs can be found either in the _log.txt file that is output alongside models converted with BBMOD CLI or BBMOD GUI, or they can be retrieved in code with method BBMOD_Model.find_node_id.

Tip: Use method find_node_id only once for each bone and store the ID into a variable for better performance.

/// @desc Create event
handRightID = modCharacter.find_node_id("HandRight");
/// @desc Draw event
bbmod_material_reset();

// Draw character
var _bodyMatrix = matrix_build(x, y, z, 0, 0, direction, 1, 1, 1);
matrix_set(matrix_world, _bodyMatrix);
animationPlayer.submit();

// Draw attachment
var _matrixHand = animationPlayer.get_node_transform(handRightID).ToMatrix();
var _matrixGun = matrix_multiply(_matrixHand, _bodyMatrix);
matrix_set(matrix_world, _matrixGun);
modGun.submit();

matrix_set(matrix_world, matrix_build_identity());
bbmod_material_reset();

Could not find what you were looking for?

We are still working on more tutorials. If you need additional help with BBMOD, please have a look at the documentation or join our Discord community. Thank you for your patience.

Support the development

Support us in developing BBMOD, get priority assistance and more of our amazing tools as a reward!

Become Patron

Don't miss out on a thing!

Create an account, subscribe to newsletter and get notified on new releases, tutorials and special offers.

Register Log in