Permits you to modify the bone data used for the current pose of the skeletal animation.


skeleton_bone_state_set(bone, map);

Argument Description
bone The name (as a string) of the bone.
map The (previously created) ds_map that stores the bone data.

Returns: N/A


Your skeletal animation is made up of a number of "bones", which you will have defined and given names to in your animation program, and this function can be used to set certain data for the named bone at any time. Note that this data will set the current pose for the skeleton, depending on the animation set used, and the function requires a previously created ds_map, which should have the following keys and their required values:

This function is provided so that you can "intercept" animation data and modify it before it is drawn on the screen, and as such you would want to use it in the Animation Update event, since this event is triggered just before the Draw Events.

Note that you can use the same map you filled out using the skeleton_bone_state_get function, even though it contains the additional "World" keys and values. Since these refer to read-only values, setting them with this function will have no affect.

IMPORTANT: Spine integration in GameMaker: Studio is a Pro licence feature and will not work in the Free/Standard versions.


var map = ds_map_create();
skeleton_bone_state_get("head", map);
var xx = ds_map_find_value(map, "worldX");
var yy = ds_map_find_value(map, "worldY");
var deltax = mouse_x - (x + xx);
var deltay = mouse_y - (y + yy);
var angle = arctan2(deltay, deltax);
var angle = point_direction(xx, yy, mouse_x, mouse_y);
ds_map_replace(map, "angle", -angle * 180 / pi);
skeleton_bone_state_set("head", map);

The above code creates a ds_map and then populates it with the data from the bone named "head". It then extracts the world position for the bone, and uses that data to set the "angle" of the bone to track the mouse position in the game.

Back: Skeletal Animations
Next: skeleton_slot_data
© Copyright YoYo Games Ltd. 2018 All Rights Reserved