mark

  • 4 sept. 2014
  • Inscrit 23 avr. 2014
  • Mitch a écrit
    mark a écrit
    Nate a écrit

    It's neat, though with pretty painful setup and animating. Also the CCD IK isn't deterministic and uses more CPU. The angle limits are nice and we'd like to support that. Spine's IK is only the first version. 🙂

    Yep, but I was suggesting incorporating ideas from this into the Unity workflow for Spine, not replacing the Spine workflow 😉

    The nice thing about my skeleton utility tools is that you are totally welcome to setup IK using those scripts by setting the "BoneComponent" (renamed it; more on that later) to Transform mode and letting the SimpleCCD script handle the rest.

    Cool! Really looking forward to this stuff! 🙂

    Nate a écrit

    It's neat, though with pretty painful setup and animating. Also the CCD IK isn't deterministic and uses more CPU. The angle limits are nice and we'd like to support that. Spine's IK is only the first version. 🙂

    Yep, but I was suggesting incorporating ideas from this into the Unity workflow for Spine, not replacing the Spine workflow 😉

    Just wanted to give a heads-up for the following video from Unite 2014. They demoed creating a 2d character with the help of the new 2d hierarchy, some IK scripts and then animated in mecanim.
    What might be interesting here is the way they have integrated support for IK with handles and gizmos for angle limits.
    Who knows - this might be able to be Mitch-ified? 😉

    Unite 2014 - 2D Best Practices In Unity http://youtu.be/HM17mAmLd7k
    Example code - https://www.dropbox.com/s/kmssm4bc4saezvv/Unite%20Seattle%202D%20Examples.zip

  • I can't remember exactly why we did it this way. We had a good reason at the time 😉
    The question is, why even allow multiple skeletons in the same file if there are limitations on how you can use them?

    Logically, the "Set parent" feature should still work the way I described. It doesn't make much sense not to allow moving hierarchies around within the tree.
    And there is no copy/paste either? 🙁

  • For some reason we have created our character in 2 separate skeletons - 1 for the head and 1 for the body. We would like to combine those into 1 skeleton now and also have all animations moved.

    The obvious answer would be to choose the head bone in the head skeleton and choose "Set parent" and then choose the root bone in the body skeleton to reparent it. But when we choose "Set parent", everything in the hierarchy is greyed out. :bang:

    How do we combine 2 skeletons with animations into 1 skeleton?


    So I'm guessing that this function is supposed to work and that someone is working on implementing it? :p

    • Modifié
  • edrache a écrit

    Yes, please, make a little tutorial. This is so awesome! 🙂

    hwadock a écrit

    Wow thanks. I will make it try~ 🙂

    Awesome! :rock:

  • Hi!

    I saw the fantastic animations you did of the 2 girls.
    I'm wondering if you are looking for work? I'd love to have you on our team.

    Thanks, Mark

  • Mitch a écrit
    mark a écrit
    Nate a écrit

    IK runtime support is coming soon. Set an IK constraint so the eye bone always points to the eye target bone. Use Mitch's stuff to move the eye target bone where you want and the eye bone automatically rotates to point at it.

    OK, sounds great! I'd love an example from Mitch when this is all in place. Everything is so bleeding-edge at the moment that I can't see all of the moving parts or how to use them 😉

    From other posts I see that IK runtime support for Unity will be coming in the next week or so - would be great!

    Yep - I'm waiting on Nate to get the true Spine-IK stuff ready so I can be sure to support it 100% with SkeletonUtility. Also, rxmarcus posted a video of runtime IK working using my bleeding edge Spine Extensions with an IK rig and gun controller I whipped up for it - that code will also go out soon too; just would rather release it when all the IK stuff goes live to avoid codebase overlap and confusion 🙂

    Cool! Really looking forward to it all coming together and seeing the cool examples.
    I did see the rxmarcus video and it's very nice 🙂
    I'm totally into Unity now (and Spine of course 😉) so I really appreciate the extra Unity love with the simplified workflows and any cool examples 8)

  • Nate a écrit

    IK runtime support is coming soon. Set an IK constraint so the eye bone always points to the eye target bone. Use Mitch's stuff to move the eye target bone where you want and the eye bone automatically rotates to point at it.

    OK, sounds great! I'd love an example from Mitch when this is all in place. Everything is so bleeding-edge at the moment that I can't see all of the moving parts or how to use them 😉

    From other posts I see that IK runtime support for Unity will be coming in the next week or so - would be great!

  • Nate a écrit

    Look at support for eyes can be done with IK. Since the IK target is a bone, using Mitch's magic you can just move the BoneComponent GameObject where you want and set the mix so it is fully controlling the IK target bone.

    Cool! But is there runtime support for IK yet? Or we don't need it at runtime?
    How would we set this up? I can't wrap my head around how it would work :bang:

  • This is really awesome work and now the integration looks really professional! This is the love that the Unity editor support needed.

    Some more gizmo info in the scene view would be great, for debugging, designing etc (icons with slot names attached to each slot, current slot name, rotation, bone length etc that you can toggle on/off)

    Some more things I'd like to see (and now I'm just thinking greedily and maybe things like this belong in examples 😉 ):

    • For the ragdoll effect - I'd love to be able to apply it interactively like in the "Clumsy Ninja" app so if I pick up one of my characters by 1 of its bones at runtime, then it "hangs" realistically from the selected bone until the character is placed on the ground again https://itunes.apple.com/se/app/clumsy-ninja/id561416817?l=en&mt=8
    • A built-in helper to provide "look-at" support for eyes. After setting up which bones are eyes and pupils and the extent of the eye whites, then a simple script attached at runtime to a game object should allow the eyes to look at and follow the movement of it. A similar script could be used for targeting systems too for weapons that should point at a crosshair game object or at a target.
    • Like you intimated in the video, automatic creation of colliders based on the mesh would be great
  • Ahh - that did it! I needed to use the UV info.

    Rect atlasRect = new Rect (imageRegion.uvs [RegionAttachment.X1] * atlasRegion.page.width, imageRegion.uvs [RegionAttachment.Y1] * atlasRegion.page.height, (imageRegion.uvs [RegionAttachment.X3] - imageRegion.uvs [RegionAttachment.X1]) * atlasRegion.page.width, (imageRegion.uvs [RegionAttachment.Y3] - imageRegion.uvs [RegionAttachment.Y1]) * atlasRegion.page.height);
    

    And then I just rotate the image if needed (I'm guessing images are only ever rotated left in the atlas):

              if (atlasRegion.rotate) {
                spriteGameObject.transform.Rotate (new Vector3 (0.0f, 0.0f, 270.0f));
              }
    

    Thanks for the help! :happy:

  • OK - I got that working, sort of. I am creating a Sprite and adding it as a child GameObject, but the rect I'm getting from the atlas region is not getting the correct region from the atlas. :p

    Slot slot = skeletonAnimation.skeleton.FindSlot ("head_gear");
    RegionAttachment imageRegion = slot.Attachment as RegionAttachment;
    imageRegion.A = 0.7f;
    
    AtlasRegion atlasRegion = imageRegion.RendererObject as AtlasRegion;
    Material material = (Material)atlasRegion.page.rendererObject;
    Rect atlasRect = new Rect (atlasRegion.x, atlasRegion.y, atlasRegion.width, atlasRegion.height);
    Sprite sprite = Sprite.Create (material.mainTexture as Texture2D, atlasRect, new Vector2 (0.5f, 0.5f));
    
    GameObject spriteGameObject = new GameObject ("DragSprite");
    spriteGameObject.transform.parent = skeletonAnimation.transform;
    spriteGameObject.AddComponent<SpriteRenderer> ();
    spriteGameObject.GetComponent<SpriteRenderer> ().sprite = sprite;
    

    sed to use the

    imageRegion.uvs;

    to get the correct rect in the atlas and in that case, how do I do that?

    • Modifié
  • I'm trying to get hold of the actual image for a slot so that I can let the user drag it off the character and vice versa drag a new item to the slot.
    I've got the following code working for finding the slot and setting the alpha on the slot image. But how do I get the actual image so I can drag it around?:

    Vector3 wp = Camera.main.ScreenToWorldPoint (Input.mousePosition);
    Vector2 touchPos = new Vector2 (wp.x, wp.y);
    if (boxColliderHeadGear == Physics2D.OverlapPoint (touchPos)) {
      slot = skeletonAnimation.skeleton.FindSlot ("head_gear");
      imageRegion = slot.Attachment as RegionAttachment;
      imageRegion.A = 0.7f;
      xOriginal = imageRegion.X;
      yOriginal = imageRegion.Y;
      Debug.Log ("Tapped head gear...");
    }
    
  • That was it! There was no rotation key on the first frame so it was running with the last set rotation.
    Thanks very much! 🙂

  • OK - project is sent via email.

    Thanks, Mark

    • Modifié
  • I have a spine animation running in Unity that looks perfect the first time I run it:

    The second time (and every subsequent time) I run the animation, the 2 bones for the 1st and 2nd car of the rollercoaster seem to have been rotated. I know it looks even more fun, but it's not so safe 🙂