Game Development Reference
In-Depth Information
Objective complete - mini debriefing
In this section, we created the rocket prefab and particle effects that will appear when
the player clicks on fire . It seems like we didn't see any progress in this section, but we will
definitely see the progress in the last step, so be prepared!
First, we created the Explosion particle system, which contains the Flame , Light , and
FireSmoke elements. We also created the AutoDestroyParticle element to control
the time this particle takes to be destroyed from the scene. In this Rocket script, we also
controlled the intensity of the light related to the particle's appearance. We used the In-
voke() function to call the KillObject() function after the timeout (4.0
seconds) parameter.
Next, we created the Rocket script, we used @script RequireCompon-
ent(ConstantForce) in Unity JavaScript and [RequireCompon-
ent(typeof(ConstantForce))] in C# to tell the script to acquire the Con-
stantForce component for the rocket prefab; this will tell Unity to automatically add
the ConstantForce component when we add this component to the object.
Note
ConstantForce is one of the Physics components in Unity that will add a constant
force to the RigidBody object ( ConstantForce works with the RigidBody com-
ponents, so when we add ConstantForce to our object, Unity will automatically add
the RigidBody object as well), which will contain the properties that we can use to con-
trol the rocket's movements. For more detail, have a look at the following website:
http://docs.unity3d.com/Documentation/Components/class-ConstantForce.html
In this script, we also checked whether the rocket collides with other objects in the scene.
This will trigger the script to instantiate the Explosion particle on the point that it collided
by using ContactPoint . Then, we created the FireTrail particle and attached to the
rocket object.
Finally, we created the Smoke particle and attached it to the gun barrel, which will be
triggered when the player shoots and this will be done in the next step.
Search WWH ::




Custom Search