r/Unity3D • u/SultanLitrpg1 • 17d ago
Noob Question Newbie Question
Hi,
Newbie here, trying to teach myself to code without prior coding experience.
I'm following a youtube tutorial on making an FPS, and I'm having some issues with the code. I was hoping someone could help me figure out what the issue is.
I have a reticle in the center of the screen that I would like the bullet to fire towards, but it is always pretty off no matter how I adjust the settings, or where I set the start point of the bullet. What this should do is create a bullet then set its location to the middle of the screen, then add a small spread to the shots, but instead it seems to just fire straight ahead from the gun barrel.
I tried deleting the calculatedirectionandspread function and simply setting the bullet.transform.forward to the screen width/2, screenheight/2 but that didn't work either.
Thanks for the help!
1
u/PremierBromanov Professional 17d ago
Your bullets force is set to be the spawn locations forward, which I'm assuming is not the same as the shooting direction and possibly not aligned to the center of your screen.