Dev Blog: Galton Board 2

The more I thought about this project, the more I realized the need to adjust my plan to fit the requirements of the assignment. Yes, I could add buttons for different peg configurations. Yes, I could pick just the right textures for the spheres so they’re gorgeous chrome. Yes, I could make the bins narrower so they show height accumulations relative to a normal distribution curve superimposed on the front. Yes, I want it to spawn exactly 100 spheres at random locations across the top rather than dump the original sphere-swarm in the center. Yes, I could tweak the pins so I get something closer to a normal distribution (a necessity if I want to use this for a stats demo in one of my classes).

But the assignment was to make a prototype of something that counted something and displayed the count; what I could do was racing far ahead of what I needed to do.

So, since it’s a prototype, the roughed out physical board is sufficient as-is. I just need to get it to count. There’s already a counter, but my concept was that each bin would count separately. Again, for a prototype, I’ll just make the counting script have a separate counter for each with a test for the bin tag before incrementing. I’m absolutely certain there’s a better solution, but this will meet the requirements.

Made a counter for each bin, an if/else if test for the bin tags to add to the count. But going to update the display, I notice that the provided script doesn’t display things the way the Unity Learn lesson taught. The lesson implemented TextMeshPro, while the default script in the project used the old UnityEngine.UI Text. Updated to TMPro after some searching online and seeing basically all the responses saying Text sucks and TMPro is the future.

It took a while to find all the places where the old UI.Text system needed to be updated, but eventually that did seem to be the solution. Note to self: Be consistent in what text renderer you use.

There are still some weird things that I haven’t tracked down yet. For example, when I run the prototype, the label for “Bin A” switches to “BinA” (without the space) but none of the other ones do, even though they are duplicates of the first. Or, in the Console, it produces NullReferenceExceptions for the line in Start() where I set countH to zero…but not for any of the other bin-count variables. But each bin counts separately and the display displays them, which satisfies the assignment.

At this point I’ll turn it in, but keep these notes for what to fix (previous paragraph) and what to do next (first paragraph) for when I come back to this prototype. Perfect? No. Is it what I want it to be? No. But sufficient? Yes.

Leave a Comment

Filed under Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.