The Vital Guide To Unity3D Interviewing
At the moment of writing this guide, there are 4.5 million registered Unity3D developers, and it is far more popular than any other game development software. It is accessible to hobbyist and professionals alike, and thus you can expect developers of all caliber during your interview process. However, that is only half of the battle, as there are a wide array of skillsets within the Unity3D development platform. This guide will not only help you identify a perfect candidate who is a real Unitiy3D expert, but it will also help you ensure that candidate is the perfect fit for your project’s needs.
Narrowing Candidates by Requirements
Unity is extremely diverse, and thus being a Unity3D developer can mean having experience in a wide range of topics. This is a critical point to make, since your interviewee could be the top Unity3d developer, but still not be a fit for your needs because their skill set may not align.
Ideally, you will want a candidate who has “done it before”. For example, if you are making a 3D console game, he should have shipped console game before. Alternatively, a candidate may be an excellent 2D mobile developer, and while he could potentially pick up 3D skills quickly that isn’t the point of this discussion. To go even further, even if he has experience on the particular platform you are targeting, you may want to focus even more narrowly on the tasks he performed and compare them to the tasks you require. A Unity3D developer who shipped a major 3D mobile title might sound very impressive, but if his experience was solely UI/UX for that title, he might not be able to help you create the AI or game logic for your upcoming title.
Thus, it is critical for you to define which platforms you are targeting, and what skill sets you will require. Here are some questions to answer internally before you begin your search.
Q: Which Platforms will you be supporting?
Unity3D supports a wide range of platforms, including Mobile, Console, Web, PC, Mac, VR, AR, and more.
While Unity does a good job of making deployment to each platform fairly painless, it is important that the candidate has shipped at least one title on your desired platform, as each platform has particular nuances that will be uncovered during development. For example, some libraries and features are not supported by the WebGL target due to HTML5 canvas security limitations.
Q: Is the project going to be 2D or 3D?
While Unity3D was originally 3D only and 2D with third party plugins, it now supports 2D projects natively. Many developers will have experience in both, but some may be more inclined in one of the two environments, as they each have their technical hurdles. For example, 3D development may involve more extensive cameras, lighting, textures, and models, while 2D development may focus more on sprites, animations, and tweening.
Q: Is it an existing project or a new project, and which language is used?
If you are dealing with an existing project, you will need to figure out if the interviewee is proficient in UnityScript or C#, as Unity3D supports both languages and your source code typically uses one. It is important to test their general C# or UnityScript programming skills, in addition to the questions laid out in this document.
Q: Will the project integrate with a back-end server?
Does the applicant have experience with Unity3D’s
NetworkManager class, or experience working with a custom back-end using RESTful API? An example question to verify applicants experience using back-end services could be: “How would you access a RESTful API from Unity3D?” Possible solutions include using Unity’s
HttpWebRequest, or using Unity3D’s asset store and downloading Best HTTP. The Best HTTP costs money, but it is worth the expense in many cases as the
WWW class is missing a few features and
HttpWebRequest is not supported on all platforms.
Q: Will the project have a single player AI?
Assessing the extent of someone’s AI abilities are outside the scope of this guide. However, a good starting point may be to ask how they would go about navigating between two squares on a grid. Solutions should include them recursively checking adjacent squares while tracking locations they have already visited until they reach the destination. A follow-up question could be how to ensure the solution finds the shortest distance. In this case, they will need to track the distance traveled during the recursion and ignore any routes that go beyond the minimum distance found.
Q: Will the interviewee be in charge of UI/UX?
There are a variety of UI tools within Unity3D. The question is, which ones do they have the most experience with and which do they prefer? An interviewee should know the pros and cons of each, and be able to describe why they favor one over another.
The latest Unity version 5 offers its own UI
uGUI, but in its current form it is somewhat limited and is missing many components that could be considered standard, such as drop down menus. Other highly used UI platforms are
NGUI is probably the most popular alternative, due to the number of widgets that it supports out of the box, but it can be complex. Bottom line, Unity’s native
uGUI should be used as long as its fundamental features cover the needs of the project. If it does not, then
NGUI is worth considering. Alternatively, if the interviewee has chosen a different toolset, then they should be able to give rational reasons as to why.
Q: Explain what a prefab is, and when it is used.
A prefab is a template for a
GameObject. It contains the object itself, as well as the children and behaviors that are attached to it. Prefabs are useful in that they can be reused, and if you make changes to the prefab, it will update all instances in the project. For example, in the game Asteroids a prefab could be used for the asteroid. The developer could spawn multiple identical asteroids throughout space by referencing the prefab. Later, if the artist wants to change the color of all of the asteroids in the game, it would be as simple as changing one texture in a single prefab.
This should be a straightforward question for a Unity3D developer of any level, but it leads to some more challenging questions below.
Q: In the game Asteroids, when an asteroid explodes, it is replaced by three smaller asteroids. What would be the drawback of instantiating three prefabs for this event?
Instantiating prefabs during runtime within Unity can be very costly on the CPU. In CPU extensive games or meager computer systems, you will see noticeable drops in framerate whenever instantiating occurs. Thus, it is typically poor design to instantiate prefabs in the middle of the action, as when the asteroid explodes the player will experience a hitch or lag.
Q: Explain how you can mitigate the performance limitations of instantiating prefabs.
One acceptable practice for reducing the lag mentioned in the question before is to create object pools. An object pool is an array of objects that are instantiated before being used. This is especially useful when there are a large number of items that will be utilized, such as the asteroids in our example. A script could load up the desired number of objects, and store references to each in the array. As asteroids spawn, they would be removed from the array and made visible in the scene. As asteroids explode, they would be deleted from the scene and stored back in the array to be reused.
An alternative solution would be to have the objects loaded within the scene. This solution typically works best when there are a small number of objects that will be used, and then it is easy to manage the assets in a scene. A good example of this would be a particle explosion every time the player’ ship explodes. An object pool would not make sense here, considering there would only be a need for one such prefab in the scene, assuming your ship can only explode once. But you also want to avoid instantiating the effect at runtime, since it may lag or hitch during the death sequence. Thus, in this scenario, keeping a reference in the scene may be the best option.
Q: Explain the downsides of using object pools, and how can you mitigate them?
The problem that arises with object pools is that each of these objects need to be stored in memory. This can be an issue on low memory devices such as mobile, as you may not be able to store references to everything that could be spawned within the memory allotted.
Mitigating this issue is a balancing act between memory crashes and CPU lag. First and foremost, compile time macros should be used to ensure optimizations and cuts only affect low-end machines, and that object pools are still used to the fullest on high-end machines. On the low-end machines, object pools and caching should be used with caution in that only the high-frequency options should be put in the pool, and at the minimum number of objects possible for a better experience. Low-frequency objects may either need to be spun up at runtime, causing the occasional lag on the low-end device, or design decisions may need to be made to remove those objects for the low-end machine. For example, particle effects and explosions may need to be withdrawn from the low-end experience. A smooth running game without particles is much preferred to a laggy game with them. Cached assets should be cleared as soon as they are no longer used. Some machines provide a low memory warning which can be helpful in determining when the cache needs to be cleared.
Q: Discuss how you would structure the classes of an Asteroids game?
This is a very broad question with many acceptable answers. The point of the question is to focus on when the developer chooses to use composition versus inheritance. If they do not answer adequately enough, you may need to steer them in the right direction, or ask them directly to describe the pros and cons of composition versus inheritance in a Unity environment.
First and foremost, inheritance means a class extends another class. An example would be a class called Orange that could extend a parent class called Fruit. The class Fruit would define the properties such as seed type, for example. Orange inherits properties from the Fruit class, so it has seeds as well, but it also extends the Fruit class with additional properties such as having a peel.
Composition, on the other hand, is used when combining multiple classes. In the Orange example above, there would be no Fruit class. Instead, we could have a class for Seeds and another for Peel. The Orange would then store references to the Seeds class and the Peel class, and thus it would be composed of those classes.
Unity uses composition extensively, as its foundation relies on the entity component or entity behavior architectural pattern. In this regard, everything in a scene is considered a
GameObject, or entity. Each
GameObject contains a list of behaviors or components that define it, which is by definition composition.
Therefore, back to the original Asteroids question. The interviewee should construct their classes in a way to take advantage of the entity behavior model. In the game Asteroids, there are two types of enemies, asteroids and alien ships. Below we will look at how one could break down these enemy types into classes by comparing implementations using inheritance versus composition.
Inheritance In an inheritance setup, there would most likely be three classes needed. A base class which we will call Enemy, and then two derived classes which we will call Asteroid and AlienShip. The base class would handle all functionality shared by both the Asteroid and AlienShip such as tracking hit points. The derived classes would add additional functionality. For example, the derived AlienShip could handle the ship’s flying and shooting functionality.
In a composition setup, we would most likely start with the same Enemy class that handles the hit points. But instead of extending it, we would use Unity’s entity behavior model to apply additional behaviors (classes) to it that add the functionality we seek. To create the alien ship, we could create a class that handles movement (MovementBehavior) and another that handles shooting (ShootingBehavior). We would then attach all three classes, Enemy, MovementBehavior, and ShootingBehavior to a
GameObject to create the alien ship.
At first glance composition seems more intuitive, but as the game design grows in complexity and new features are added, it becomes exceedingly difficult to manage as each change may alter all derived classes. Composition, on the other hand, is immensely flexible and allows developers to create new features, or in this case enemies, just by adding and removing behaviors. That being said, both setups can be appropriate depending on the scenario. The key during the interview is to make sure the interviewee knows that both options exist, and can explain why they chose one over the other.
Q: Explain what Draw Calls are.
Draw Calls are the number of times the processor needs to change materials when rendering the scene. If there are 100 objects in a scene, and each have unique materials, then there would be 100 draw calls. However, if each object used the same material or sprite sheet, then all 100 objects could be drawn in a single draw call.
Q: How can you reduce Draw Calls?
Draw calls can be used by batching images to use the same material or sprite sheet. For example, in a 2D game we could have a character who has sprites for his head, body, and legs. Each sprite is unique, and thus it would take three draw calls to render the character. To reduce this, we could combine all three sprites into a single sprite sheet, and then draw calls would be reduced to one since all three sections could be drawn at once.
A good follow-up question here would be to say the character picks up a cape which appears above the head but behind the body in z-order. The cape is on a different sprite sheet than the character. How many draw calls would it take to render the character and cape on the two sprite sheets? The answer is three. Even though there are two sprite sheets involved, z-order causes three switches to occur. First, the character sprite sheet is used to draw the head. Then, the cape sprite sheet is used to draw the cape. In the end, the character sprite sheet is used to draw the body and legs. The body and legs can not be drawn at the same time as the head since the cape appears between them.
Q: How would you find a memory leak?
The key to this question is to make sure the developer knows the ins and outs of the profiler and uses them often. The profiler has a memory section which allows you to take a detailed snapshot of everything stored in memory. You can then search through this list and look for anything that should be cleaned up. Adding names to items helps distinguish them within the list.
We just scratched the tip of the iceberg of knowledge needed to be a top Unity3D developer. We hope that questions and answers presented in this guide will help you pinpoint the ideal developer for your project, by not only finding top Unity3D developers but finding the best developer for your particular needs.