Time for action – creating the EnergyPulse prefab
We need to create a prefab of our EnergyPulse projectile. Use the following screenshot of the Inspector as a guide for these steps.
- Create a new prefab by navigating to Assets | Create | Prefab and name it
EnergyPulse
. - Add a Sphere to the Scene.
- Position its Transform to
0
,0
,0
. - Scale its Transform to
0.5
,0.5
,0.5
. - On the Sphere Collider, check Is Trigger.
- Uncheck Mesh Renderer.
- Add a Rigidbody Component.
- Turn off Gravity.
- Add the script
EnergyPulsePower
(see Appendix B). - Add a Trail Renderer Component by navigating toComponent | Effects | Trail Renderer.
- Drag a GoodOrb prefab to the Good Orb property on the Energy Pulse Power (Script).
- Set the Trail Renderer properties as shown in the following screenshot.
- Drag Sphere onto the newly created, empty EnergyPulse prefab.
- Now delete Sphere from Scene
What just happened?
Now that we have our EnergyPulse to shoot, we can shoot them in two States: PlayStateScene1_2
and PlayStateScene2
.