Based on my knowledge, the issue you're experiencing with Slot Alpha not reaching perfect 0 during Blend Tree interpolation is related to how Unity's Mecanim handles blending with Spine animations.
The Core Problem
When using Mecanim's Blend Trees, Unity is blending between multiple animations simultaneously. If you have animations blending together where:
- Animation A has Weapon A at Alpha 1, Weapon B at Alpha 0
- Animation B has Weapon A at Alpha 1, Weapon B at Alpha 0
- The Setup Pose has both weapons at Alpha 1
During blending, the Setup Pose values can influence the interpolation, preventing you from achieving a true Alpha 0.
Recommended Solutions
1. Set Mix Duration to Zero
When transitioning between animations in your Blend Tree, ensure that the mix duration is set to 0. This prevents unwanted interpolation between the Setup Pose and your animations.
2. Ensure All Animations Have Explicit Keyframes
Make sure every single animation in your Blend Tree has explicit keyframes for the Slot Alpha values at Frame 0 for both Weapon A and Weapon B. Don't rely on the Setup Pose values - explicitly key the alpha you want in each animation.
3. Use Animation Events or Direct Slot Manipulation
Instead of relying solely on Mecanim's blending for alpha values, consider:
- Using animation events to directly set slot alpha via script
- Directly manipulating slot color/alpha through code when switching weapon states
Here's an example approach:
// Get reference to your skeleton
var skeleton = GetComponent<SkeletonAnimation>().Skeleton;
// Find the weapon slots
var weaponASlot = skeleton.FindSlot("WeaponA");
var weaponBSlot = skeleton.FindSlot("WeaponB");
// Set alpha directly
weaponASlot.A = 1f; // Fully visible
weaponBSlot.A = 0f; // Completely hidden
4. Consider Using Attachment Swapping Instead
Rather than using alpha blending, consider switching attachments visibility entirely:
var slot = skeleton.FindSlot("WeaponSlot");
slot.Attachment = skeleton.GetAttachment(slot.Data.Index, "WeaponA");
// Or null to hide
5. Check Your Blend Tree Settings
In your 2D Simple Directional Blend Tree, verify that:
- All animation clips are properly assigned to all positions
- No positions are left empty (which might cause Unity to blend with default values)
- The blend parameter ranges are correctly configured
Important Note About Alpha Blending
Keep in mind that alpha blending can cause semi-transparent parts to show through when multiple animations are blended. This is a fundamental rendering issue with transparency. If you need perfect weapon switching without any ghosting, attachment swapping (hiding/showing different attachments) is generally more reliable than alpha blending.
The ghosting you're seeing during blend tree interpolation is unfortunately a known limitation when blending multiple animations that modify alpha values through Mecanim. The most robust solution is often to handle weapon visibility through direct slot manipulation in code rather than relying on Mecanim's blending for alpha values.