Hello!

I am trying to move one Spine skeleton animation character to another Spine skeleton animation character so that they're positioned right next to each other on this x-axis.

Prior to using spine I did this with Unity's Sprite Render by using:

TargetPosition = new Vector3
((TargetEnemy.transform.position.x - (Hero.Sprite.bounds.extents.x + TargetEnemy.Sprite.bounds.extents.x)), 
TargetEnemy.transform.position.y, 
TargetEnemy.transform.position.z);

I'd like to accomplish the same exact thing with Spine skeleton animations. I believe I can use skeleton.GetBounds() to do this, correct?

I tried my best to search the forums on how to use this function, but I don't really understand it.
I believe you can set it up this way, but I don't know what I'm supposed to use for the 3rd argument 'width'.

var offset = new Vector2();
var size = new Vector2();
skeleton.GetBounds(offset,size,[]);

Once I successfully obtain offset,size, & width from GetBounds(), how can I use this information to know the distance from the middle of the skeleton animation to the right side of it?

I hope this all made sense. Thanks so much for taking the time! 😃

    Related Discussions
    ...

    @PayasoPrince Please check out the spine-unity specific method documentation here, as each runtime will be a bit different than the reference API due to language and runtime constraints:
    https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-csharp/src/Skeleton.cs#L610-L616
    In general it's always recommended to jump to the method you want to call using your IDE's go to definition functionality, as the parameters are always documented there.

    As you might have found out, the parameters are output and reference parameters, so you need to pass them using the out and ref keywords.

    float x, y, width, height;
    float[] vertexBuffer = null;
    skeleton.GetBounds (out x, out y, out width, out height, ref vertexBuffer);

    In spine-unity, you might want to use skeletonAnimation.GetComponent<MeshRenderer>().bounds instead if you based your previous solution on sprite.bounds. As usual, cache the MeshRenderer reference instead of calling GetComponent() all the time if it's outside of an Editor script.

      Harald
      Using Mesh.bounds worked perfectly. Thanks dude!

      Glad it helped.