• Editor
  • Two animations with same graphics

Hello guys, I'm new here so I think this question is basic but still I need help...
Anyways...

I want to have two animations (one is idle and one is sleeping) with same graphics I imported from PSD with spine script. So basically I already did animations but every time I switch between those two I need some graphics to be turned off/on in first and some graphics to be turned off/on in second animation.

So practically I want Hand, Hand2 and Dewey_arm to be turned-on in Idle animation and as I switch to zzz animation I want Mouth and Dewey_arm_zzz to be turned on and these 3 from first animation to be turned off.
How can I do it? Should I have two root bones or two skins? 🙂

Related Discussions
...

To achieve the desired effect of switching between two animations (idle and sleeping) with different graphics being turned on and off, you can use skins and skin placeholders in Spine. Here’s a step-by-step guide on how to set this up:

  1. Create Skins:

    • Create two skins, one for each animation state (e.g., IdleSkin and SleepingSkin).
    • Assign the appropriate attachments to each skin. For example, IdleSkin will have Hand, Hand2, and Dewey_arm, while SleepingSkin will have Mouth and Dewey_arm_zzz.
  2. Set Up Skin Placeholders:

    • Use skin placeholders to manage the visibility of attachments. This allows you to switch between different sets of attachments without affecting the animations.
    • Place the attachments for each state in their respective skin placeholders.
  3. Key Skin Visibility:

    • In your animations, key the visibility of the skin placeholders. For the idle animation, ensure that the placeholders for Hand, Hand2, and Dewey_arm are visible, and for the sleeping animation, ensure that Mouth and Dewey_arm_zzz are visible.
  4. Switch Skins at Runtime:

    • At runtime, switch between the skins using your game logic. When the character transitions from idle to sleeping, change the skin from IdleSkin to SleepingSkin.

Here’s an example of how you might set this up in code:

// Assuming you have a reference to your skeleton animation component
SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();

// Set the skin to IdleSkin
skeletonAnimation.Skeleton.SetSkin("IdleSkin");
skeletonAnimation.Skeleton.SetToSetupPose();
skeletonAnimation.AnimationState.SetAnimation(0, "idle", true);

// Later, when switching to the sleeping animation
skeletonAnimation.Skeleton.SetSkin("SleepingSkin");
skeletonAnimation.Skeleton.SetToSetupPose();
skeletonAnimation.AnimationState.SetAnimation(0, "sleeping", true);

By using skins and skin placeholders, you can easily manage the visibility of different attachments for each animation state without needing to create multiple root bones or complex setups.

For more detailed information on skins, you can refer to the Spine User Guide on Skins.

Can some human answer?

The bot gives an answer immediately, which is often helpful. Us humans will always be along soon if the bot wasn't useful.

It sounds like you can just key slot attachment visibility in your animations:
https://esotericsoftware.com/spine-keys#Slot-attachment

  • AkeSake ответили на это сообщение.
  • AkeSake оценил это.

    Nate Hey Nate I didn't know that...I saw AI answer which was correct but still not something I was looking for. Sorry for rushing 🙂

    And thank you for your answer, you solved my problem 🙂

    No worries! Cool, I'm glad you got it solved.

    🙂