Forum rules - please read before posting.

Scratch Card AC Integration

Hi Chris,

So I have installed the Scratch Card asset and asked the creator how to call an event on completion of the scratch card effect. He explained this method:

You can subscribe to the EraseProgress.OnProgress event:

public EraseProgress EraseProgress;
...
void Start()
{
    EraseProgress.OnProgress += OnEraseProgress;
} 
private void OnEraseProgress(float progress)
{   
    if (progress > 0.9f)
    {
         //Do something here
    }
    var value = Mathf.Round(progress * 100f).ToString();  
    Debug.Log(string.Format("Progress: {0}%", value));
}

Essentially I want to be able to call a cutscene when erase progress is complete, can you help?

Thanks!

Comments

  • public EraseProgress EraseProgress;
    public AC.Cutscene cutsceneOnComplete;
    ...
    void Start()
    {
        EraseProgress.OnProgress += OnEraseProgress;
    }
    private void OnEraseProgress(float progress)
    {
        if (progress > 0.9f)
        {
             //Do something here
             cutsceneOnComplete.Interact ();
        }
        var value = Mathf.Round(progress * 100f).ToString();  
        Debug.Log(string.Format("Progress: {0}%", value));
    }
    
  • So would the cutscene name need to be called CutsceneOnComplete? What do i call this script? Thanks

  • And again, what code do I need at the top to ensure it works in AC?

  • I modified your code snippet above to make it call a cutscene. There's no naming convention - you just have to assign the cutscene inside the "Cutscene On Complete" Inspector field.

    The code you posted was not a complete script, however. You'd still need to place it inside a C# MonoBehaviour as normal with the correct namespace, as the creator is informing you.

  • gotcha! thanks!

  • Ok that's awesome thank you! Now, my next issue is:

    When erase progress is complete, my action list cutscene keeps playing over and over and I need to somehow tell the script to only play once or to turn variable off? I wonder if you could help, again, I am a bit of a newbie when it comes to scripting.

    Please see attached script and video for my scratchcard and background:

    https://www.dropbox.com/s/yk53izo2s15m77v/ScrachCard.mov?dl=0

    Thanks for all your help!

  • I don't see an attached script, but to adapt the code sample above:

    public EraseProgress EraseProgress;
    public AC.Cutscene cutsceneOnComplete;
    private bool hasRun;
    ...
    void Start()
    {
        EraseProgress.OnProgress += OnEraseProgress;
    }
    private void OnEraseProgress(float progress)
    {
        if (progress > 0.9f)
        {
            if (!hasRun)
            {
                //Do something here
                cutsceneOnComplete.Interact ();
                hasRun = true;
            }
        }
        var value = Mathf.Round(progress * 100f).ToString();  
        Debug.Log(string.Format("Progress: {0}%", value));
    }
    
  • awesome thanks!

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.