Game Development Reference
In-Depth Information
impacts with a hazard with a KillOnCollision script component, the script would try to access and
call the GotoRagdoll() function of the GoRagdoll script component, but the enemy drone doesn't
have one and so an error would occur. With the conditional in place, if the collision involves the
enemy drone, the conditional tests false and does not execute the code block calling GotoRagdoll() ,
so no error occurs.
There is an almost infinite number of combinations of error types and scenarios within which they
might occur. The best way to learn how to address errors is in practice by finding and solving them
as they appear, and by learning more respective exception-handling code as you go. You'll come
across many examples within the sample projects and tutorials that Unity has made available in
the Asset Store. If you are presented with an error you can't resolve, the best next step is to do a
quick search on the Unity3D Community page, under Answers and/or Forums. Most likely you'll find
someone has run into the same problem and the answer is readily available.
Summary
This chapter has been fairly intensive, as you pulled together the player character and hazard
prototypes to implement the game design you put together in the previous chapter. You experienced
the iterative process of game design and created cheat codes to facilitate testing the obstacle
course prototype. You learned how to revive the player character and make him invincible.
As you progressed through each hazard zone, you learned more ways to utilize scripts and prefabs
to quickly populate the scene with hazards in regular patterns or with unpredictable randomization.
Through the use of scripts you learned to adjust hazard game object properties in real time in
response to player movement. You also created your first enemy and animated it with a simple
AI script.
You repurposed assets to conserve time and resources for prototype development. You also
refactored code to make it more efficient and you learned the basics of debugging. Whew—you
covered a lot of ground and got a lot of good practice in design implementation as you fleshed out
the obstacle course prototype. Great job!
 
Search WWH ::




Custom Search