I am looking for help on my FPS project. I have a shooting system that uses RayCasting. It comes from the FPS cam which is inside the player. It works but occasionally will hit either the gun or my arms if I move certain directions/ways. I have changed the point of origin to a separate point that is just beyond the camera, but moving that too far out to avoid hitting the gun and arms creates its own problem. How do I make the raycast simply ignore the gun and arms. I have tried numerous methods I have found, the “best” one seeming to be to add a LayerMask to the Physics.Raycast(), however that does not work. The arms are on their own layer as are the guns, yet any layermask I select in the inspector outside of “Nothing”, the gun and arms will be hit. I have changed the settings in the unity project settings as one video suggested, that does nothing either. Any feedback would be great, thank you. Code Below:
Personally I got into the habit of using named arguments for things that have overloads or multiple same typed arguments such as this. It’s not for everyone but it certain can be useful.