Game Development Reference
In-Depth Information
(5) projectileInstance.rigidbody.AddForce
(projectileInstance.transform.forward * force,
ForceMode.Impulse);
5.
Add a force to the Projectile prefab's rigidbody using the AddForce()
function, giving it a Vector3 forward direction with a magnitude of the
adjustable force factor, using ForceMode.Impulse , which applies all of the
force instantaneously.
(6) Destroy(projectileInstance, 2);
6.
For performance purposes you don't want these Projectile game objects
piling up out of view, so each clone will be destroyed after two seconds.
Select the Launcher game object in the Hierarchy. Drag the Projectile prefab from the Assets ➤
Prefabs folder and drop it into the Projectile property field of the LaunchProjectile script. The Tracer
Fire obstacle is finished. Drag the Cannon game object from the Hierarchy to the Assets ➤ Prefabs
folder in the Project folder to make it a prefab asset. Save the script, save the scene, and save the
project. Playtest, and now you have a killer projectile Tracer Fire Obstacle. Great job!
Summary
Now you have a handle on creating particle systems and effects using Shuriken, and you're
beginning to imagine how your obstacle course will shape up into a game. You've added
LineRenderer and TrailRenderer to your bag of visual effects as you created a number of new
obstacles prefabs for the Obstacle Course scene.
Before dispersing these obstacles randomly along the course, in the next chapter, among other
things, you will be introduced to the theories of game design, which will in turn give you guidance on
the hows and whys behind designing scene layouts like the obstacle course.
 
Search WWH ::




Custom Search