Hi! Ok, so I’m coding a first-person shooter. I currently place the origin of any new bullet that’s fired directly in front of the character by using this:
What I’d like to do is place the bullet origin a little off-centered to the right a little, as if being fired by a right-handed person. I have in my head how it’s probably done, but I can’t figure out if it’s a rotation based on the character as the origin, or just how to offset the position of the bullet relative to the character “cam”.
Once I’m able to position the starting point of the bullet as if it were from the tip of a gun positioned in the right hand of the player, I’m going to cast the bullet trajectory toward whatever object is collided with in the ray cast.
if you do that, you’ll have “instant” bullet, which is not the case irl and in most games. Bullets are fast, but they aren’t “instant”
If you keep in your idea of doing a ray test, keep in mind that you should use the “ray” from the physics engine. Why ? Because if you use the ray in the scenegraph your bullet will hit things like particles.
A “big” problem when you have a camera and a gun and a bullet fired from the gun is that the bullet will never hit the “center” of the camera if its trajectory is // with the camera. I mean : you have 2 different point (the camera and the tip of the gun) and 2 line parallel. It’s the reason why in some fps people shoot “from their head”.
remember that with you approach people will maybe be able to shoot through wall (as the tip of the gun will maybe be able to go through the wall)