Game Development Reference
In-Depth Information
Step 2. Open blob.js and modify as shown in Listing 2.18 .
Listing 2.18 Destroying Another Object in an Explosion
var explosion:GameObject;
var explosionLife:float = 5.0;
...
private var stuckOn: GameObject;
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.name != "First Person
Controller")
{
//record the object we are stuck on
stuckOn = collision.gameObject;
rigidbody.isKinematic = true;
...
}
function Explode()
{
. . .
Destroy(exp, explosionLife);
//if we are stuck on an object named Door //destroy it
if(stuckOn && stuckOn.name == "Door")
{
Destroy(stuckOn);
}
}
. . .
Step 3. Save and play. Position a sticky explosive on the door and
watch as it gets destroyed.
Step 4. Create more cubes to fit in the other doorways. Ensure that
they are named “Door” in the Hierarchy and any sticky explosive will
destroy them. If you want to blow up anything the sticky bullet is
stuck to, remove the if statement testing for just “Doors” (and the
associated {} )! Be careful though, you might fall through the floor if
you destroy the wrong object.
Secondary Motion
Secondary motion brings the game environment to life. The simplest of
movements can hint at a dynamic realistic environment with a life of its own.
For example, a swaying tree or moving grass provides the illusion of a light
breeze while also suggesting to the player that these are living things. How
often have you been for a walk in a forest that doesn't move around you?
Even in a still warehouse environment there is the opportunity to add
secondary motion to add extra atmosphere to the scene.
Search Nedrilad ::




Custom Search