[GAME] My Glitch Garden with some miner changes, including extra Attackers!

Thanks @Rob.

So I did another build with “development build” checked, but it’s still coming up with the same error.

I right clicked and selected Inspect. I found the error (Uncaught abort 113) in the console, and click the link next it, and it highlighted a bit of code that says “throw e;” that’s under an “if” statement. Dunno what that means! :thinking:

I’ve updated the original post with a link to the current build. :slight_smile:

Hi James,

Can you pop up screenshots of the Other Settings and Publishing Settings for the WebGL build - you can find these by clicking on Player Settings under the Build Settings menu item. They click to expand etc.

Here they are, @Rob.

1 Like

Hi James,

Thanks.

Ok, lets try a couple of things to see if we can either resolve the issue, or, get more information to see what the issue is. Failing all of that, if you are happy to share the full projects files with me I will happily take a look and try a build at this end also, but before that, lets try the following;

  • Under Optimization, untick Strip Engine Code
  • Rebuild
  • Republish
  • Test to see if the error occurs

Note, your build will be larger this time round

If the error still occurs;

  • Under Optimization, replace the tick for Strip Engine Code
  • Under Logging, set all five options to Full
  • Under Publishing Settings, change the Enable Exceptions to Full
  • Rebuild
  • Republish
  • Update the link so that I can access it also to have a look at the stack trace again please :slight_smile:

Please run the above two scenarios separately and let me know what happens :slight_smile:

Cool, thanks Rob. It’s getting late here now so I’ll try those out tomorrow.

1 Like

No problem at all - we will nail this :slight_smile:

Happy Joining the Community anniversary also!

1 Like

@Rob

OK, so did the first thing, unticked “Strip Engine Code”, and still got the error.

So here’s the link with all “Logging” options, and “Enable Exeptions”, to set to Full. I’ll put it here for convenience. :slight_smile:

https://gamebucket.io/game/d1f9379c-511c-492c-89d1-8c7bb24e0704

Thanks!

1 Like

Hi James,

Ok, this is more useful. You are getting NullReferenceExceptions, and they seem to stem from a method on your Defender class called AddStarFive which receives a parameter of type int named amountFive.

The original course code looked like this;

public void AddStars(int amount)
{
    starDisplay.AddStars(amount);
}

Does yours differ in any way? If not, the only obviously thing in this code which could be a null reference would be starDisplay.

This was originally a private variable which was the initialised in the Start method, here’s the original code;

using UnityEngine;

public class Defender : MonoBehaviour
{
    public int starCost = 100;
    private StarDisplay starDisplay;

    /// <summary>
    /// Initialise
    /// </summary>
    private void Start()
    {
        starDisplay = GameObject.FindObjectOfType<StarDisplay>();
    }

    /// <summary>
    /// Adds the specified number of stars to the player's star count
    /// </summary>
    /// <param name="amount">The amount of stars to add</param>
    public void AddStars(int amount)
    {
        starDisplay.AddStars(amount);
    }
}

Also, I note that the error will appear when ever I click, which may suggest an issue with the player input handling.

Lets start here and see what you find, if you are not entirely sure, post up the full code from your Defender.cs file and I’ll take a look :slight_smile:

1 Like

Ah! OK, so I do use the addStars method, but I also made the addStarsFive method, as well as other scripts with “five” in the name, specifically for level 5 since you start with more stars on that level. Actually, since both methods get called when you place a Defender down, I have been getting NullReference errors in the Unity editor. But the game carried on regardless so I didn’t think it mattered. Well, it looks like it does!

Anyway, I think I’ve stopped the error by making the addStars int public and setting it in the Inspector on each level instead, and not using the “five” scripts and methods at all (it’s so obvious, I can’t believe I didn’t do it before!). But again, it’s getting late here so I’ll finish it off tomorrow, re-build and post here, and we’ll see if it worked!

1 Like

I shall look forward to seeing your update James.

That’s solved it. :slight_smile: Re-built and uploaded it, and it works. No errors. I’ve updated the first post with the new link. Thanks, @Rob, I appreciate you taking the time to help.

Now, I looked in to what you said about there appearing to be two Star Trophies on one square. Turns out you can spawn any defender on one square infinitely if you keep clicking it. I had a quick go at solving that but couldn’t work it out. To be honest I don’t know if I will bother with that. I’ll leave it how it for the moment and, well, people can exploit it if they want. :stuck_out_tongue:

1 Like

Hi James,

Sorry for the delay responding, I have been away for a few days.

Glad to hear that this has resolved the issue - nice to be able to play without the errors :slight_smile:

Regarding the infinite spawning, I don’t recall this being an issue, but perhaps when I pushed through I didn’t experience it / test enough. I do recall having some oddities with being able to spawn defenders outside of the main area on occasion if I was quick enough with the mouse.

No worries with regards to not investigating it now, enjoying moving on with the course :slight_smile:

1 Like

Privacy & Terms