Game Development Reference
In-Depth Information
Figure 8-5. The single potato in position in the bazooka
4.
Focus the scene to the PotatoAmmo.
5.
Select the Fire Point, and use “Move to View” from the GameObject menu to
move it to the potato.
6.
Reselect PotatoAmmo, and add a Capsule Collider to it.
7.
Adjust its size and orientation as necessary.
A Radius of 0.05 and Height of 0.2 on the Z axis should work well.
8.
Add a Rigidbody component to PotatoAmmo.
9.
Drag the Projectile script onto it as well.
10.
Drag PotatoAmmo into the Prefabs' Misc folder to create a prefab for it.
11.
Delete the Sphere prefab while you are there.
12.
Delete PotatoAmmo from the scene.
13.
Select the Fire Point object, and assign PotatoAmmo prefab as the Projectile.
14.
Click Play, and test the new projectile.
Because the potato is instantiated slightly in front of the bazooka's muzzle, the potato should not
interfere with the parent object's colliders. When parent-child collision is a problem, you can use
Physics.IgnoreCollision(<the projectile's collider>, <the weapon's collider>) . That line
would go just below the rigidbody.velocity line.
Search WWH ::




Custom Search