My bullets in my FPS game are off centre when shooting. This isn’t due to any gravity effects, or what not. Even if I apply a straight ray, it’s still off centre.
I think the reason i changed it was cause players could press F9 (and thus their mouse is free) can now click anywhere on screen, and thus can shoot in an array of different positions
I use fast cast, which just passes a origin and direction value. The origin is the fire point at the end of the gun, and direction should be where you are aiming, so I don’t think anything else is necessary (other than the direction)
FPS games were simply never designed to be done on the server only and sadly cheaters will always exist. But there is different countermeasures, like for ex rate limiting the amount of requests (no one just spams remotes when it comes to machine guns, you send them in a packet of information, it’s the reason why in cod mw if you got bad internet you’ll get killed instantly and your headphones will make a loud noise)
Now thinking of it, i wonder if i do a cheeky thing here. Try putting this in your code and tell me if it works
local u = Vector3.new(0.5, 0.5, 1) --dont normalize/.Unit
local l = head.LookVector
local o = head.Position
local x = l/-o+u
local dir = u*x
local h = dir.Unit * 500
local actualDirSendThisToFastCast = (h-o).Unit --see what i did there lmao
local Origin = firePoint
local Direction = Camera.CFrame.LookVector.Unit
local ActiveCast = Caster:Fire(Origin, Direction, SPEED, CastBehavior) -- Fire shot
Obviously SPEED and CastBehaviour are irrelevant to this problem
function Fire(direction)
if Tool.Parent:IsA("Backpack") then return end
local directionalCF = CFrame.new(Vector3.new(), direction)
local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector
local humanoidRootPart = Tool.Parent:WaitForChild("HumanoidRootPart", 1)
local myMovementSpeed = humanoidRootPart.Velocity
local modifiedBulletSpeed = (direction * BULLET_SPEED)
if PIERCE_DEMO then
CastBehavior.CanPierceFunction = CanRayPierce
end
local simBullet = Caster:Fire(FirePointObject.WorldPosition, direction, modifiedBulletSpeed, CastBehavior)
PlayFireSound()
end
`local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector`
Now add a value to CFrame.fromOrientation on x and try if it fits
example:
local direction = (directionalCF * CFrame.fromOrientation(-0.05, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector