In this tutorial we are looking at how to make our player shoot bullets!
To Achieve this we add a new script called “PlayerShooting”. In this script we reference a public GameObject called “bulletPrefab”. This name comes from the fact that the bullet we will be referencing a Prefab.
A Prefab is a GameObject that you have created and then simply dragged into a folder in your project. What this does is create an object that Unity can then reference over and over again as a kind of blueprint for something that you mind create over and over again, like a bullet. I usually call my folder “Prefabs” but this name is changeable and you can have multiple folders.
This is the first time we see the use of Instantiation. This is the term for creating instances or clones/copies of a given object. Every time we click the left mouse button, we instantiate a new bullet using the “bulletPrefab” as a blueprint. We then access the RigidBody component of this bullet and apply a force in the direction our player is facing. Enjoy!