Forum rules - please read before posting.

Using Object > Fade Sprite action on instantiated Players

Hi, the Object > Fade Sprite action is very convinent in fading sprite in and out. But it doesn't have an option to fade the instantiated player sprite (AC 1.72.4). I tried to make a custom action for this by modifying the ActionSpriteFade.cs script, but I don't know how to assign KickStarter.player.spriteChild.GetComponent() to runtimeSpriteFader.

Is there some lines of code I can add to ActionSpriteFade.cs to fade the player sprite?

Comments

  • I don't know how to assign KickStarter.player.spriteChild.GetComponent() to runtimeSpriteFader.

    Try this:

    runtimeSpriteFader = KickStarter.player.spriteChild.GetComponent<SpriteFader> ();
    
  • I tried adding that to the beginning of Run() but it doesn't work:

    public override float Run()
            {
                runtimeSpriteFader = KickStarter.player.spriteChild.GetComponent<SpriteFader>();
    
                if (runtimeSpriteFader == null)
                {
                    return 0f;
                }
    
                if (!isRunning)
                {
                    isRunning = true;
    
                    runtimeSpriteFader.Fade(fadeType, fadeSpeed);
    
                    if (willWait)
                    {
                        return fadeSpeed;
                    }
                }
                else
                {
                    isRunning = false;
                }
    
                return 0f;
            }
    

    I have changed the file name to ActionPlayerSpriteFade.cs to avoid crashing with the original ActionSpriteFade.cs. And I am using AC 1.72.4. Any other changes needed?

  • If the SpriteFader component is on the active Player's Sprite Child, that should be enough - provided you're using the modified Action and not the original.

    Did you duplicate the Action with a new Title and install it as a custom Action?

  • It works! I forgot about the sprite fader component during testing.

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.