During this week I will focus on developing a shooting mechanic.
The code is formed from two parts. The first part focuses on a RayCast that has the role of detecting the layers and retain them. The ray uses a line render for visual output. This part also contains the begging of the code for an object that can be hit. The ray will stop once the maximum distance has been reached. This part is the projectile itself that is saved as a PreFab.
The second part of the code is attached to an empty GameObject, that acts as the muzzle of the gun. This is the area that calls the Projectile PreFab, to which is attached the first part of the code. What this code does is that it handles the time between rounds, creating them at a decided interval, using the Projectile Prefab
The third script that is present only contains a simple function, Destroy(), which eliminates the prefabs after an appointed time.