T
thcha

  • 12 juin
  • Inscrit 20 mai 2024

    thcha Is this the right way to implement it?
    Or is it the right way to set only states such as idle and move and get the state from the code and set the direction?

    As Spinebot mentioned, there is no single right way. In general having a Mecanim subtree with single states for 8-direction movement is a valid approach. I don't see why it would not scale well with 16-direction movement (creating all the animations would likely be the larger effort).

    Note however that the hybrid approach shown in "Mecanim Logic SkeletonAnimation view" of controlling animation via Mecanim while in the end targeting a SkeletonAnimation component is not the primary recommended approach. This always comes with some limitations, as it's mapping one limited system onto another. In general we always recommend directly using the SkeletonAnimation component and SkeletonAnimation.AnimationState if you can, and issuing the respective AnimationState.SetAnimation() calls via code. Your movement components can use AnimationReferenceAsset object references if you prefer drag-and-drop assignment of animations, or have [SpineAnimation][SerializeField] string animationUp; if you prefer selecting animations from a list.

  • @thcha We've just released a new Spine URP Shaders UPM package supporting this feature:
    https://esotericsoftware.com/spine-unity-download
    It can be found under the name Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly ZWrite.
    Note: we added it as a separate shader instead of a property since additional passes (DepthOnly and DepthNormals) which are not required on the normal outline shader.

    Note that you will need to change Render Queue to Alpha Test for use with a DoF effect.

    • thcha There is no example of an implementation of an 8-directional character in the example scenes of the spine-unity runtime, but you can see how to handle the skeleton's animation using the Animator Controller in Spine Examples/ Other Examples/StateMachine SkeletonAnimation/Mecanim Logic SkeletonAnimation View.

      This scene and the example scripts that are used in the scene should be very helpful to you. (The example scripts are attached to the Hero GameObject.)

    • thcha If your skeleton is relatively simple, you can set up a single skeleton which can face 5 directions, with the remaining 3 directions obtained by setting the Skeleton's scaleX to -1. You can then simply make sure that the appropriate animations play as you manipulate them in the game. You can see an example of a simple skeleton facing 8 directions here: https://esotericsoftware.com/spine-twitch#video-FPaqO0Xlh4w

      However, in the case of complex skeletons, it can be difficult to manage 8 directions in one skeleton. While covering all directions with a single skeleton has the advantage of making it easy to reuse the same animation, it also means that changes made in one direction may affect poses in other directions, and before you know it, poses in other directions may be broken. Therefore, for skeletons that are more complex than the one linked above, and that require complex animations such as attack and special skill moves, it may be easier to manage them by splitting them into two skeletons, one for the front and one for the back, or even three skeletons, for example by creating a separate skeleton for the side view.
      If you were to do this, you would have two or three SkeletonGameObjects under one GameObject (say, a GameObject named Player) and switch the skeleton to be displayed according to the direction the Player is facing.

      You may find the following thread helpful:
      https://zh.esotericsoftware.com/forum/d/12335-animating-isometric-character-recommendations

    • @thcha Please note that the URP 2D Shadow casting system works completely different than the normal 3D shadow casting pipeline. Did you get a non-Spine GameObject to cast proper 2D shadows in the same scene?

      In general you need a ShadowCaster2D component, see the documentation here:
      https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@17.0/manual/2DShadows.html
      Note that ShadowCaster2D is not designed for animated objects which change shape every frame. You can however set the Shadow Caster 2D Casting Source to Shape Editor and define the shape for your skeleton.