To fire projectiles in the direction of movement, follow these steps:
- Create a new Sphere GameObject (by navigating to Create | 3D Object | Sphere). Set its size as (0.5, 0.5, 0.5).
- In the Inspector window, add a RigidBody component to Sphere (go to Physics | RigidBody).
- In the Project window, create a new blue material named m_blue (go to Create | Material).
- Apply the m_blue material to your sphere.
- Use your Sphere GameObject to create a new prefab in the Project window named prefab_projectile. First, create a new folder in the Project window named Prefabs, then drag the Sphere GameObject from the Hierarchy window into the folder in the Project window. Rename this new prefab file prefab_projectile.
- Now, delete the Sphere GameObject from the scene (that is, delete it from the Hierarchy window).
- Ensure set the position of the Cube-player GameObject to (0, 0.5, 0).
- Create a new cube named...