Hey guys, just picked up 2D Toolkit the other day - enjoying it so far. Immediately went through the Whack a Mole tutorial and I believe I've found two bugs, and two possible fixes, in Unity 4.3. These are in both the step by step directions, and the RestOfGame_Complete.unitypackage download.
#1 - in MainGameScript.csrandomMole = (int)Random.Range(0, moles.Count - 1);
while(moles[randomMole].sprite.gameObject.activeSelf)
{
randomMole = (int)Random.Range(0, moles.Count - 1);
}
As is, the code appears to never select the last MoleUnit prefab in your game. If you have 3, it will select from 2. If you have 6, it will choose between 5.
Changing
randomMole = (int)Random.Range(0, moles.Count - 1);
to
randomMole = (int)Random.Range(0, moles.Count);
appears to solve this issue without introducing any new ones.
Note that (1, moles.Count) does not seem to work - it will also skip a mole and possibly introduce lockups. (see below)
#2 - Related, also in MainGameScript.csmoleLimit = 3;
Unity will hang after running for a short period of time if the number of (selectable) MoleUnits is less than the moleLimit. For example, 1 or 2 moles with a limit of 3. The whole program locks up and needs to be shut down via taskmanager. Setting the range to (0, moles.Count) and making sure the moleLimit is not greater than the number of MoleUnits you have appears to solve this. The above range fix is important as without it, even 3 moleUnits with a moleLimit of 3 will crash due to only two being available. I'm not entirely sure what's causing the lockup, however.
I'm a web developer by trade, very new to Unity and only a hobbyist game developer, so while I have some idea of what's going on it's only the gist.
But I didn't see these fixes while looking around, so thought I'd post them here in the hopes someone will find this useful.