Raycasts Lag Behind When Strafing

Hello, everyone!

Very recently, I noticed that in my game, Redshift: Arena, bullets appear to hit several feet behind or infront of where your reticle is - which is the last thing I want in a game that is heavily dependent on accuracy and not standing still, much like the earlier arena fps games of the late 1990s. Any help would be greatly appreciated! :slight_smile:

The effect is much worse in gameplay, so the screenshots don’t exactly cut it.

Screenshots


Raycast Stuff
  local ray = Ray.new(game.Players.LocalPlayer.Character.Head.Position, (mouse.Hit.p - game.Players.LocalPlayer.Character.Head.Position).unit * 900 + Vector3.new(math.random(-2,2),math.random(-2,2),math.random(-2,2)).unit*gunset.gunSettings.Spread)
	local part, position = workspace:FindPartOnRayWithIgnoreList(ray, ignoreList, false, true)

I should also mention that the player’s default walkspeed is 32, and when you pick up the speed bost, it becomes 64.

1 Like

Are you positioning the bullets to mouse.Hit.p (or the ray made with it)?
Have you tried removing the spread modifiers to see what happens?

1 Like

Same deal happens if I remove the spread modifiers.

Let me double check to see if the bullets are going to mouse.hit.p

Edit: I modified the server and client scripts to see if it would change anything - and to my surprise - it alleviated some of the lag at a distance. In the client script script, I was sending over the position of the gun instead of the head. I now send the position of the head, which alleviates the problem for the most part.

Edit #2: Actually, after doing more testing (online, this time) the lag appears to be extreme.


1 Like

You should be doing everything visual on the client so that lag doesn’t affect anything.

You may also want to put hit detection on the client, for a better experience (although it’s a bit easier to hack).

Hit detection is on the client.

However, bullet holes and such are not.

I don’t think it’d make a difference if I made bullet holes appear on the client - since there’d have to be a FireAllClients which is fired from the server, which still involves the server - which then means lag.

Yes, but it’s most important for the player shooting. The others will not likely notice a difference, but the person shooting will and that’s who the problem really effects.

So do it on the client, then send it to the server to send it to all the other players.

2 Likes

Alright.

That makes more sense to me actually.

I’m not sure this is a bug. If you’re strafing at 32-64 studs/s, You should see the hit effects to the left or right, because the very soonest anything will be displayed is the next frame, at which point your camera is at least a stud to the side, possibly several, even if this is all done on the client. I tried strafing along a wall and shooting at specific points in the texture pattern, and the bullet holes and particle effect were positioned correctly (where my reticle was on the frame I clicked). I personally wouldn’t advise trying to fix this, it seems technically correct to me. You’d see this same thing strafing along a wall with a real gun if you could strafe that fast. 64 studs/second is about 43 miles per hour if you figure the player is a 6 foot human. No one can strafe at 43 miles per hour, in fact that’s about 10x actual speed.

4 Likes