So, I’m making an FPS game and run into a problem when I shoot the bullet out of the gun at the Muzzle Position as a starting point. But the if I rotate the camera around fast, the bullet trail position seems to be off comparing to the where the muzzle position currently is.
So as an attempt to fix this problem, I’ve tried to predict where the muzzle will be if we rotate the camera by using a loop and some line of code to figure it out:
local LastMuzzleCFrame = CFrame.new()
RunService.RenderStepped:Connect(function()
local PredictedMuzzlePosition = (Muzzle.CFrame:ToObjectSpace(LastMuzzleCFrame)).Position
LastMuzzleCFrame = Muzzle.CFrame
--Send it to a server
end)
But it didn’t work that well because the same problem still occurs.
If you are creating the shot on the server, that is because of network lag, pretty normal in every game, to hide that effect you would have to cast a local bullet.
Takes time for the info to arrive at the server, then the part is created, and another time to go back to clients.
Also, that prediction effect you created might make it look normal in the shooter’s screen, but all the other player will se the bullet offsetted when that players shoots.
Yes, and I forgot to mentioned that the PredictedMuzzlePosition is just an add-on to the Muzzle position so the full script is gonna look like this
--ServerSide
remoteevent.OnServerEvent:Connect(function(player, MuzzlePos, PredictedPosition) -- the current muzzlepos is already included and the Predicted Pos is just an addon to that
local BulletCurrentPosition = MuzzlePos + PredictedPosition + . . .
end)
Therefore, I notice fps games like Bad Business for example, their bullet position is pretty much precise to the muzzle position, so do you think that they have the similar approach of casting a local bullet in order to hide the delay?