Game Development Reference
In-Depth Information
1.
Select the Baby ZB.
2.
Set its Rigidbody to Is Kinematic, and drag it onto the Stork Group object in
the Hierarchy view.
You may be wondering why you aren't adding the Baby ZB to the Bundle rather than the Stork
Group. When a parented object is unparented, its local transforms, the offset from its parent, are
converted to world coordinates. Re-parenting it using the original transforms will work for a child but
break down for a grandchild. As long as the Baby ZBs objects are re-parented to the Stork for the
reset, you can parent them to the bundle afterwards for the drop.
3.
Adjust the Baby ZB's Z position until it is behind the bundle, and give it a bit
of rotation (Figure 9-48 ).
Figure 9-48. The baby zombie bunny nestled in the bundle
When the bundle hits, the baby zombie bunny should bounce out. You will be turning off its Is
Kinematic property and letting physics do the rest. The only problem is that it will pop back up
to where it was when the bundle was dropped. Just as you did with the bundle, you will have
to unparent the Baby ZB before turning the physics on. It will also eventually have to return to
its original position just like the Stork and bundle, so you will be creating a similar script to the
BundleManager. Feel free to copy and paste code to speed things up.
4.
Create a new C# Script in the Game Scripts folder, and name it
BabyZBHandler .
5.
Add the following variables:
Vector3 startLocation; // the object's original location
float zRotation; // the object's original z rotation
GameObject bundle; // the bundle
GameObject stork; // the stork
Search WWH ::




Custom Search