Sure, you have access to the entire mesh at runtime. MeshAttachment extends VertexAttachment. You want to look at VertexAttachment vertices
. For a non-weighted mesh it's just x,y values for each vertex. For a weighted mesh you also need VertexAttachment bones
. Your code would look something like:
Skeleton skeleton = ...
MeshAttachment mesh = ...
Vector2 tempVector2 = new Vector2();
int[] bones = mesh.getBones();
float[] vertices = mesh.getVertices();
Array<Bone> skeletonBones = skeleton.getBones();
for (int v = 0, b = 0, n = vertices.length; v < n;) {
int boneCount = bones[b++];
for (int ii = 0; ii < boneCount; ii++, v += 3) {
Bone bone = skeletonBones.get(bones[b++]);
// For example, to move the mesh down 25 in world coordinates:
Vector2 position = bone.worldToLocal(tempVector2.set(bone.getWorldX(), bone.getWorldY() - 25));
vertices[v] += position.x;
vertices[v + 1] += position.y;
}
}
You would do this only once, not every frame (unless you want the mesh to move every frame). Note this will affect every instance of this mesh attachment, so you may want to modify a copy.
A simpler way is, as you mentioned, to move a bone that the attachments you want to move are parented to. You can move the root bone to move the whole skeleton (or set the Skeleton position) or you can create a bone specifically for moving the attachments you want to move.