I have been making a first person game called "shoot the ball into the bin". The camera is in a cylinder as a player also the cylinder has collision.
I have been struggling with the main driver of the game. Like in most first person shooter games, you shoot out from the center point of the camera or the cursor.
I have trouble replicating that. The code I have so far for the shooting is:
Instantiate(prefab, new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, Camera.main.transform.position.z), Camera.main.transform.rotation);
(Credits to @derHugo for helping me instantiate a prefab)
But that just spawns it on top of the player, not in front of it. How do I make it shoot away from the player, but also in front of the player, not on top.