Affinity

  • 19 de Abr de 2021
  • Se unió 18 de Ago de 2016
  • Pharan escribió

    SkeletonUtility doesn't work with SkeletonGraphic.

    If you can describe your more specific need though, we can maybe come up with a solution, especially if SkeletonGraphic is really the better option for you.

    I don't know if the specific component is SkeletonGraphic that I want, but whatever works I'm fine with it.
    However, since SkeletonGraphic seemed to be the current go-to component for UI element it not utilizing SkeletonUtility was a big con(only if SkeletonGraphic is really the recommended component for UI).
    I'm attaching my HUD design and following with what I'm up to with the 'red section of the HUD.'

    Basically, the HP bar is a combination gauge and icon.
    Icons are the actual HP like hearts in Zelda, and the gauge just modifies its length and gap distances according to those Icons.
    Icons must be attached to the right gap, and for that utilizing a bone as an anchor is a very efficient solution. And because in cases of like this(UI utilizing bones) I'm very confused of SkeletonGraphic's purpose and stuck to SkeletonAnimation as I've been always doing with any other character rigs.

  • Pharan escribió

    Yes, SkeletonGraphic is for use with Unity UI. It derives from UnityEngine.UI.MaskableGraphic so it works with Unity's UI.

    What do you mean by "not able to play animated clips of the skeleton"?
    Are you calling SkeletonGraphic.AnimationState.SetAnimation, similar to the way you would in SkeletonAnimation?

    No. Not yet.
    Since I was new to this specific component I was testing things out with only inspector manipulation.
    If the component still should play clips of the skeleton without any script control but only with inspector manipulation, then I assume I am doing something wrong.

    However, am I able to use SkeletonUtility + SkeletonUtilityBone just as I would to with SkeletonAnimation?
    Because of the latter I had to use SkeletonAnimation in replacement for SkeletonGraphic.

  • I've made several skeletons for my game's HUD / UI.
    Unlike how I've been using Spine till now SkeletonGraphic seemed somewhat more fitting than SkeletonAnimation, but that was just a wild guess.

    What I'm really asking is:
    Is SkeletonGraphic for the use of Canvas / UI element?
    If so, I'm currently not able to play animated clips of the skeleton with SkeletonGraphic, but able to do so with SkeletonAnimation.

    If you've some experience with above, or experience with making UI stuff with Spine any input would be helpful.
    Thanks.

  • Pharan escribió

    It may have been packed in a way that the folder arrangement doesn't match how it was defined in the skeletons individually. You'd have to define them in the skeleton in such a way that it matches the way they're packed.
    For example, if the attachment on the skeleton is defined as "hand" and it's packed as "goblin/hand", it will not be able to find it and assume it's missing.

    If this isn't the problem, could you send us the json and atlas file? unity@esotericsoftware.com

    Also, could you open the other question as a separate topic? Things are likely to get messy if we clump it with this topic.

    Thanks, Pharan! I think your advice is spot-on with the issue.
    For the record .spine is inside FolderA, input texture for texture packer are in FolderB(which is inside FolderA) and output route is in FolderC(also inside FolderA that makes both FolderB & FolderC in FolderA).

    So, changing 'hand' which is 'goblin/hand,' how do I do this?

  • So, I've got 5 Skeletons and all image pieces collected in one directory.

    The issue is when I use Sprite Packer and get all my textures neat in one output Unity does not find any other atlas asset but only one and screams back 'Missing Regions' for all the rest of skeleton's slots.

    There's no issue of implementing the same export when I don't use Sprite Packer and generate atlas per skeleton, however, I'm guessing I didn't use it right or something..? But still, there're only so many settings options for me to look through to resolve this myself, and I still haven't got it.

    ++ This piece I'm doing is a UI piece. I've only used SkeletonAnimation or SkeletonAnimator components, but SkeletonGraphic seemed like a fitting concept, but SkeletonGraphic doesn't seem to play clips by me tweaking around inspector, and couldn't use any SkeletonUtilityBone which I need quite a lot for UI element manipulation. Am I doing things right here?

  • Pharan escribió

    You need to keep an eye on those .meta files. They might be hidden and not being included in your version control so it might keep breaking. Or your version control might be destroying the information in the meta files, or the files themselves.

    This is true for any UnityEngine serialized asset or component. Not just Spine stuff. It just might have happened that meta files between users of specific scripts may have had a different setup.

    Meta file, gotcha. Since somewhen I omitted to update the meta file when updating changes of a prefab through my version control. I'll fix that.

    Anyways, I've been kept away from working with Spine for a long while now. The other scripting tasks kept me really busy; a lot to catch up. How are we doing on mecanim implementation? Is animation control in Unity sill better with hard-coding than mecanim and other FSM sorts?

  • Pharan escribió

    What do you mean by "updated it via versioning system"?

    As long as you updated it according to how Unity likes its assets to be updated (unitypackages, or straight up files with their meta file/guid info intact), it should work fine.
    If you are sharing a project with someone else and they didn't do the above, things can break when you start recombining your assets.

    For instance, I'm using Perforce for our project as the version control system. Whenever the skeletonAnimator prefab goes through Perforce it breaks a whole lot of spineUnity scripts connections. I've managed to restore them for now, but if this occurs repeatedly I think I need to change something... That something, I'm not sure what for now... Perhaps there's some more proper way of setting this up?

  • I should probably do some major overhaul of my character, but for now, fixing this is first.

    I have a player character as a prefab and updated it via versioning system.
    What changed was all the spineUnity scripts(ie: skeletonAnimator) were unlinked from the prefab's components.
    I've manually put them back to the broken prefab, however, unity still yells at me saying: The associated script cannot be loaded. I then checked through character data files and found file Player atlas_Atlas file was the only different thing than the working original prefab. Where working prefab's atlas_Atlas has 'atlas.atlas.txt' connected the broken one has 'AtlasAsset' script from Spine-unity Asset Types folder, and I cannot re-link the atlas.atlas.txt to it.

    My Unity version is 5.6.0f3

  • Pharan escribió

    This has always been the requirement with SkeletonAnimator ever since it was written.
    It's just that SkeletonAnimation and AnimationState had some major improvements just last month which applied to all runtimes.

    The fixes are not straightforwardly applicable/translatable to SkeletonAnimator since Mecanim holds the layers and times and it's sort of out of our control unless they expose more of the API or we manage some hacks to get things to work.

    I'm not even quite sure if my changes got my player animation controller any better or same or even worse now.
    What should I do? Since my knowledge toward both SkeletonAnimation and SkeletonAnimator are not that deep yet I can't clearly tell what'd happen furthermore and decide...

    What is the best known way to achieve a good animation controller with fsm at current build? Like, PlayMaker + SkeletonAnimation? Or, is just hard coding animation controls the best way to go with Unity?

  • Pharan escribió

    SkeletonAnimator has a number of limitations we are working on resolving.
    You can check the "auto-reset" checkbox on the SkeletonAnimator.

    But currently, the surest way to have clean results is to have keys for the bones that are causing problems, even if they look correct in Spine Editor.

    SkeletonAnimation does not have this requirement since these issues are handled by the internal AnimationState code, especially in 3.6.

    Sigh... so much work to do... I mean, trying to perfect anything would be the same, but since my old player had such complex animation control as well as too complex state machine to really nit pick things I changed it from SkeletonAnimation to SkeletonAnimator to utilize the mecanim and. now....

  • So, because I was still following some workflows really dated from Youtube, Pharan guided me back to where I should be with the current workflow to initial character setup. Previously my character was using SkeletonAnimation which didn't go well with mecanim without extra script to trigger animations, but now that I've got it under SkeletonAnimator things look like how they should be.

    However, I've got a problem, though.
    My character's poses are mixed after their own play: like when I play idle -> walk -> idle, then some bone rotations and positions seem mixed up. They don't go back perfectly pose after pose. Can someone point out what could have gone wrong in this case?

    edit : omitted the question part since I simply just figured out how to work with mecanim events. Still has no clue about how to resolve the pose-wrecking, though.

  • Pharan escribió

    None taken!

    The Mecanim controller and dummy animation clips generated by clicking the button on the SkeletonData Asset are the same as when you instantiate the SkeletonAnimator for the first time. There should be no difference.

    SkeletonAnimator/Mecanim integration is still less than ideal since Mecanim doesn't have all the necessary callbacks or expose as much of the internal states as we would have liked. This also makes it so that you can't see your skeleton animating in Edit mode, and still requires the dummy animation clips which can be confusing because new users expect there to be editable keys in the animation.

    We're actually looking at whether it actually makes more sense to do away with the dummy animation clips and achieve integration via StateMachineBehaviours.

    But as it is, SkeletonAnimator should work fine even if it's extensive as long as it's not doing anything that's also hackish.

    If the results are identical either ways why are my clips not played without the script I mentioned above?
    What could have gone wrong or done wrong if so?
    I'm still not able to play any clips generated by the dummy clips in mecanim though my parameters are working correctly without the behaviour scripts attached to each clip that calls SetAnimation

    edit: I found out I need to make 'SkeletonAnimator' not 'SkeletonAnimation. How I set up was with the latter. urgh... I can't tell how much extra work I'd need to to when I start over with SkeletonAnimator...

  • Pharan escribió

    If you use SkeletonAnimator, you don't need the script above.

    When you Instantiate your skeleton as a SkeletonAnimator, a Mecanim controller will be created, as well as several dummy AnimationClip assets as described in this old thread.
    You would then lay out your Mecanim controller using the dummy animation clips like normal. Blend trees should work normally.

    What SkeletonAnimator is doing at that point is just re-interpreting the state of the Mecanim state machine into poses for the skeleton.

    Damn, I didn't realize how dated those workflows I followed via Youtube were until this.
    I even got my dummy animation clips by clicking the button that generates such.
    I think I'd like to re-do the setup following your guide just now and then get back to you for the further question if I get stuck somewhere.
    Thnks a lot again!
    I think there should be more organized workflow guide as a document, though. If there already is and I just missed it, then it's either I've got dyslexia, or how they were posted were not that popping out because checking out the most recent workflow when it changes by reading forum post isn't the best thing to do such job DX, no offense.

  • Pharan escribió

    Hello! This is a two year old thread.
    This is the new way to instantiate: http://esotericsoftware.com/forum/New-Feature-Drag-and-Drop-to-instantiate-6789

    Thanks for the redirection!
    I'm kind of not getting the most current workflow to utilize mecanim atm which gets me undesired results when

    using UnityEngine;
    using System.Collections;
    using Spine.Unity;
    
    public class SpineAnimationBehaviour : StateMachineBehaviour
    {
        public string animClip;
        public int layer = 0;
        public float timeScale = 1f;
        private float normalizedTime;
        public float exitTime = .85f;
        public bool loop;
    
    private SkeletonAnimation skeletonAnimation;
    private Spine.AnimationState spineAnimationState;
    private Spine.TrackEntry trackEntry;
    
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (skeletonAnimation == null)
        {
            skeletonAnimation = animator.GetComponentInChildren<SkeletonAnimation>();
            spineAnimationState = skeletonAnimation.state;
        }
    
        trackEntry = spineAnimationState.SetAnimation(layer, animClip, loop);
        trackEntry.TimeScale = timeScale;
    
        normalizedTime = 0f;
    }
    
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        normalizedTime = trackEntry.trackTime / trackEntry.trackEnd;
    
        if(!loop && normalizedTime >= exitTime)
        {
            animator.SetTrigger("transition");
        }
    }
    
    override public void OnStateExit (Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    
    }
    
    }
    

    is what is attached to every single clip(as solitary states) in mecanim, therefore I can't really workout the blend tree.
    What I want to achieve is just like any other mecanim workflow I'd get to play clips drag & drop without needing such script as above. Is there current workflow?

  • Mitch escribió

    Ah holy crap I never pushed that patch O_O

    I fixed the lastTime calculation a while back. I'll deal with that a bit later. Sorry. Shows how much I use mecanim for anything ... 😐

    @Mitch I've got the latest versions of spine-csharp & spine-unity.
    But I don't see 'Instantiate' when I right click on SkeletonDataAsset.
    Has something changed?

  • Majicpanda escribió

    Hey Affinity, this post was for those that do not have NodeCanvas. You do not combine Node and Mecanim.

    If you use this example, you would still instantiate your animations as SpineAnimation not Animator. This one allows you to place a behavior on each mecanim node.

    Did you just mean to reply to Spine + NodeCanvas? by chance? 🙂

    Oh, I totally misunderstood when you said things about NC. The miscommunication was totally on me and my poor reading skills, so don't worry haha.

    No, I wanted any input from you since you've done what you've done and I'm still intrigued to learn it.(Still need to figure out the magic of NC, but that's another topic. It really lacks clear representation to visual scripting newbies like me)

    I still want to know what really went through your demo, though. I tried to figure out myself with your attached demo, but couldn't.
    If this method you used to utilize both mecanim node and spine skeleton animation at the same time that's what exactly could help me out with my transition animations being really turdy.

    Also, one of the problem I had trying to check out your demo was I couldn't figure out why your animation behaviour script keep giving me syntax error. if you ask me now I have to re-check it since it was some time ago, but yeah.