Game Development Reference
In-Depth Information
As you start dissecting sample projects, you will see this kind of check fairly often. If some other
game object without a Rigidbody component incidentally passed through the trigger collider,
you would get an error because your code tells the physics engine to apply an upward force,
but without a rigidbody it cannot. By adding this conditional, the game engine checks for a
Rigidbody component and if there is none, avoids the error by skipping this line of code.
You are getting a good feel for the general mechanics of Unity: In the course of gameplay the Unity
game engine makes calls to functions such as Awake() , Start() , and Update() while the physics engine
makes calls such as OnCollision() and OnTrigger() . Within these calls you write code to direct the
gameplay. Your code can take an action on the game object the script is attached to, a different game
object that is interacting physically, or any other game object. Since scripts are also components, the
script from one game object can interact with the script attached to a different game object.
Rapid Prototyping
At the time this is being written, Unity has just added a plethora of goodies for you in its Sample
Assets (beta) package in the Asset Store. Beta testing is when a software version is released for
testing by users outside of the original programming team. This can be small groups of people or
even the general public, where the intention is to get feedback for some polishing of the product
before the official version is released.
If the Sample Assets is still a beta version when you read this and you find anything from “doesn't
work” to “unexpected behavior” or even “I wish it did this,” let the folks at Unity know in the
comment thread at the bottom of the product page on the Asset Store (Figure 6-10 ).
Figure 6-10. The Sample Assets (beta) package in the Unity Asset Store
 
Search WWH ::




Custom Search