• Editor
  • Trying to use skins to alter shading on turret

We have a spine model with multiple skins that can be turned on or off. But we would also like to setup up a second variation of each of those skins for flipping the shading over. Is it possible to control that through just 1 additional skin?

So as an example:

Skin1, Skin2, Skin3 - can each be toggled on or off separately or as a combination of each other.

Can there be a SkinA, SkinB -> that switches overall sprites from the skins above to the version A or B... but doesn't affect what skins are shown in the first place.

If Skin1 is on and SkinA -> it should show Skin1A -> if Skin1, Skin2 and SkinB is on it should show -> Skin1B Skin2B.

Below are images of the turret and the currently work flow in spine.

Turret shading PSD

Turret set-up spine (current)

  • Misaki відповіли на це.
    Related Discussions
    ...

    Yes, it is possible to achieve the desired effect using Spine's skin functionality. You can create a base skin for each shading variation (SkinA, SkinB) and then combine these with the existing skins (Skin1, Skin2, Skin3) at runtime. This way, you can dynamically switch between different shading variations without affecting which skins are shown.

    Here’s how you can do it:

    1. Create Base Skins for Shading Variations: Create SkinA and SkinB, which contain the shading variations for all the attachments in Skin1, Skin2, and Skin3.

    2. Combine Skins at Runtime: Use the addSkin() method to combine the base skin (SkinA or SkinB) with the currently active skins (Skin1, Skin2, Skin3). This will allow you to apply the shading variation to the active skins.

    Here is a basic example of how you can achieve this in code:

    // Assuming you have a reference to your skeleton and skins
    Skeleton skeleton = ...;
    Skin skin1 = skeleton.data.findSkin("Skin1");
    Skin skin2 = skeleton.data.findSkin("Skin2");
    Skin skinA = skeleton.data.findSkin("SkinA");
    Skin skinB = skeleton.data.findSkin("SkinB");
    
    // Create a new skin to combine the active skins with the shading variation
    Skin combinedSkin = new Skin("combinedSkin");
    
    // Add the active skins
    combinedSkin.addSkin(skin1);
    combinedSkin.addSkin(skin2);
    
    // Add the shading variation
    combinedSkin.addSkin(skinA); // or skinB
    
    // Set the combined skin to the skeleton
    skeleton.setSkin(combinedSkin);
    skeleton.setSlotsToSetupPose();

    This approach allows you to dynamically switch between different shading variations while keeping the flexibility to toggle individual skins on or off.

    For more detailed information, you can refer to the Spine Runtime Skins documentation and the Skins view in the Spine editor.

    If we have 40 skins that can be toggled on and off. And 2 variations of each, how can we avoid creating a duplicate for each of those 40 skins. We understand how to combine these dynamically via code. We are trying to have 1 skin control the shade, and the others control the actual addons. Is that possible? Thanks!

    • Misaki відповіли на це.

      sid Hmmm, I think it should be possible to do this the way Spinebot already answered, but I think it might be easier to set attachments at runtime instead of trying to do everything with skins.
      If there is a slot named shading with attachments for shading, then you can switch which shading attachment is visible in that slot with the Skeleton setAttachment() method.
      For example, if skin 1, 2, and 3 are applied and you want to add skin A, you must re-set a new skin that combines skins 1, 2, and 3 and skin A. This is a bit redundant if you only want to change the visible attachment for one slot. Skins are useful if you need to change attachments for many slots at once, but I think in your case you may not need to bother with skins.

      paatz04

      We understand how to combine these dynamically via code. We are trying to have 1 skin control the shade, and the others control the actual addons.

      I am afraid I do not fully understand what this means. Skin combinations can only be changed via code. Things like making sure that when a particular skin is applied, certain other skins are applied as well, cannot be set within the spine editor, it has to be done via code.

      However, as the set-attachment method was introduced above, there are many other ways to change the appearance of a skeleton at runtime in addition to skins. For example, it is possible to prepare and apply an animation to change the appearance. (This can be useful if you want to use a fade in to change the appearance).