Forum rules - please read before posting.

Enabling masks applied for specific sprites in SUC animation

I have my character standing with his left side to the camera next to a fridge. He opens it with his left hand, while with the right hand, he reaches inside and takes out some food. The fridge door is not part of the animation; it is a scene object. I created a mask over the fridge door, and I would like this mask to be applied to the right hand so it looks like the character is reaching inside the fridge.

I have a similar animation with reaching into a drawer for a book, only the character is now standing with his right facing the camera and uses the oposite hand to reach in the drawer. And here comes the problem, because the mask is affecting both hands equally. I need to somehow set that the mask will affect the right hand only for one animation and the left hand only for the other. Here is what i tried:

  • There seems to be only one "universal" mask I can use that affects everything equally. So I cannot set the left hand being affected by mask1, for example.
  • The Mask Interaction state does not get recorded and cannot be changed within the animation.
  • I tried to set the mask for a Custom range to affect only the specific sprites in the player rig, but it only affects the current sorting order of the player prefab as a whole. I tried to change the sorting layer from Default to the Player's layer, but it had no effect.

At this point, I ran out of ideas. Could anyone please help?

Comments

  • This is a general Unity topic - the use of SUC isn't a factor here.

    Do you have a Sorting Group on the root? So long as only the arm you wish to mask has its Mask Interaction field set to Visible Outside Mask, and all others set to None, then only that sprite should be affected by any Sprite Mask object.

    This Mask object should also be a part of the Hierarchy (i.e its parent is the object with the same Sorting Group as the other sprites), but other than that no Custom Range option should be necessary.

  • edited March 18

    The problem is that i want the same arm to be Visible Outside Mask during one animation and have interaction set to None during another. And I cannot figure out how to make the change during gameplay.

  • Through script:

    using UnityEngine;
    
    public class SetMaskInteraction : MonoBehaviour
    {
    
        public SpriteRenderer spriteRenderer;
    
        public void SetMaskOutside ()
        {
            spriteRenderer.maskInteraction = SpriteMaskInteraction.VisibleOutsideMask;
        }
    
        public void SetMaskNone ()
        {
            spriteRenderer.maskInteraction = SpriteMaskInteraction.None;
        }
    
    }
    

    Attach to the arm sprite and use the Object: Call event Action to trigger either of the two functions on it.

  • edited April 2

    Thanks, Chris. But for some reason, it doesn't work, and after running, the fields are empty.

    However, I came up with a different solution. I made a child copy of every sprite with a mask interaction set. Then, I just turn on/off the sprite renderers of the parent or the child as part of the animation.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.