Weapon Firing

Hey,

I am currently creating a first person type shooter not technically defined what for to be honest. I am having some issues though and I was wondering if someone could help me. I want to fire my weapons bullets like how they are shot in call of duty. What I mean is when a bullet is fired say hip fire or aiming in fire the bullet always fire straight down the line of sight to the target and never moves off to the side. What I also mean is when firing a bullet using say trail renderer and I move while hip fire or aiming in the bullets always move off to the side. From what I understand is that the ray and how it calculates the firing of the shot is what causes this. I can be wrong though I am certainly not an expert. So yeah I can share a simple code of what I am saying and I am wondering if someone can help me fix it. I am using a follow camera that in LateUpdate positions it to the player head, and I am using character controller in my movement code. Also I am using the new input system.

Thank You
SuperMage
RaycastWeapon.cs (3.2 KB)

Your weapon script needs to do its thing just after the camera and player has moved. So instead of updating your camera in LateUpdate you can make the camera a child of the player and then update your weapon in LateUpdate.

Thank you, but unfortunately, I cannot do that as the animation rigging package as far as I can tell will not let me parent the camera to the player.