FPS Problem - Bullet is not flying to point where I aim at

Sorry for my bad english.

Ok so I’m working on a FPS game and everything works good so far but I have a problem with the bullets.

When I’m aiming the bullets dont go there where I aim at.
They fly a bit over the iron sight.
It only happens when I stand far away from the point i want to shoot at.
Here are some images:
(The green point helps me to show where the bullets will go)

This is when im standing close to the point:

And this is when im standing far to the point:

The current code for the bullets look like this:

local FirePart = self.ClientWeapon.Fire
local Direction = FirePart.Position + FirePart.CFrame.LookVector * self.ClientWeapon:GetAttribute("Range")		
local Rayc = Space:Raycast(FirePart.Position, Direction-FirePart.Position)

I tried many ways to fix it but nothing worked.
I wanted to ask you people maybe you know a solution for this?

The only solution that I tried before was creating an extra part for the raycast that gets used when aiming instead of the “normal” FirePart. That accually worked but I had to make the position & rotation of the part perfectly and that takes a lot of time and I need to make each small movement perfectly

You showed the code for raycasting, but not for aligning the weapon model with the camera. Please post that as well

I’m setting the Viewmodel PrimaryPart CFrame to the Camera CFrame

I edited the post at the end a bit because I forgot to tell it

Why do you expect the view model to then line up perfectly with the camera? The sights may not be in line with the center of the model, and the front and rear sights may not be colinear with the center of the model. Unless you’re using SetPivot and have carefully edited the pivot to exactly ensure that things will work out, then it would be weirdly lucky if it actually did work.

Its my first time making an FPS Game.
How can I fix this?

The Gun is for Testing (toolbox) and all parts are seperated like this:

Base - Handle - Details - Bolt - Magazine - FirePart

I’m using a Motor6d to keep the Viewmodel and the Gun Handle together and then im setting the Viewmodel PrimaryPart CFrame to the Camera CFrame.

I dont know why but I changed some settings in the Motor6d for the GunHandle and FirePart

I set the C1 Orienation X from 0 to 1.25 and it made it better?
The problem is still there if I point to a point that is further away but you wont notice it at all anymore.

1 Like

One way is to have an invisible part be the PrimaryPart and then perfectly align that with the sights.

1 Like

image
Its not correctly zeroed. Its too high up and too far to the left. Also that is not what a HK-brand sight should look like.

The green point is just a visual thing that shows me where the bullet would go with my current raycast method

I’m talking about the way you’re aiming the gun…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.