Forum begins after the advertisement:


[Part 26] PlayerCollector issue without UICoinDisplay

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 26] PlayerCollector issue without UICoinDisplay

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #18750
    Terence
    Level 31
    Keymaster
    Helpful?
    Up
    0
    ::

    In Part 26, there is an issue with the PlayerCollector script where, if you don’t have a UICoinDisplay active in the same scene as the player collector, it will create NullReferenceExceptions that can cause issues with the rest of your project.

    The fix is to simply check whether your OnCoinCollected delegate has any actions attached to it first:

    //Updates coins Display and information
    public float AddCoins(float amount)
    {
        coins += amount;
        if(onCoinCollected != null) onCoinCollected();
        return coins;
    }
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: