

If, however, this way of working is entirely as intended then I think some more powerful tools are needed to allow these sort of implicit linkages to be tracked down.įor example, just being able to recursively search all game objects' property names and their values in the project / hierarchy windows would have made it easy to locate the implicit linkage between the OnFootstep() javascript function and where it was being specified as the value of a property in the GUI.
#Unity projects angry bots code#
In fact I would argue that it does much that might be considered bad practice - certainly if I had code reviewed the scripts on the ed-209 style mech for any programmer I was managing, mentoring, or teaching they would have had significant work to do to address my concerns. I think it would be hard to argue that this might constitute best practice - certainly with regards to ease of others understanding your work. It seems to me that much of Angry Bots functionality arises from the interactions of a scattered bunch of event driven scripts with no reference to each other other than those implicit by their use - whilst I guess this is good for modularity, it makes it very hard to follow the code.Īdditionally, many scripts contain significant blocks of commented code, and no comments or documentation (that I could find) that explain how the various scripts interact to produce the desired effects. Whilst it is awesome that Unity affords this kind of freedom and expressivity through its data driven architecture there must at least be a 'best practice' way envisaged to organise this sort of code / data / code inter-reliance? I feel that this sample should be a paragon of consistent structure and organisation of assets and code - whatever might stand in for 'coding standards' in Unity terms - at the very least it should at the very least be clearly documented by comments in the scripts (which it isn't). If the answer you want to give is 'yes' I would very much like to dispute that assertion. This sample has surely already formed the basis for innumerable first forays into making games using Unity and so it should be showing best practice. So, here's the first part of my support question:

A quick look at the code in the script and, yep, that seemed to be what was calling the script. Opening the hierarchy of the Footstep Signals property eventually unearthed a property of a property (!) called 'Action' that was called 'OnFootstep'. In the end I just started trawling through all the scripts attached to the mech, and eventually found a property called 'Footstep Signals' on a script called 'MechAnimation.js' on a sub-object in the mech's gameobject hierarchy called 'mech_bot'. Still nothing specific, the closest being a couple of people asking footstep related questions. I had a mooch about in the Unity documentation and on Unity Answers. No joy, but was I looking in the right place? I changed tyhe file filter to search in all files in the whole project folder. I tried 'find in files' in Visual Studio. There's a function called OnFootstep() in this script and something must be calling it, but what? I'd got no idea where to look to find out how it might be getting called.

I'd never had a serious look at the Angry Bots sample (I originally got involved with Unity for hobby use just before the release of 3.0 which was before Angry Bots shipped with Unity), so assuming that this sample would show 'best practice' use of Unity by the people who make it I thought I'd have a look around in it to see if I was missing anything, doing anything wrong, or could be doing anything better.įor one reason or another, I ended up mooching about in the scripts attached to one of the big ED-209 style mechs and I noticed a script called 'FootStepHandler.js', so I had a look in there and found some pretty inexplicable code.

I've spent a fair amount of time messing about with Unity and generally I'm very very impressed. I currently work as the Technical Director at Gamer Camp which is a masters level course in game development taught within a simulated game studio environment. First, a little background: I've come to Unity as an Indy developer after working as a programmer / designer in the console space since 1996.
