Raycast being inconsistent

Hello, I’ve been recently making a shooter game with serversided projectiles. The problem was when I wanted to make fast projectiles, which .Touched could not handle, so I thought about using raycast between previous and current positions to check skipped frames.

The issue with this is that it most of the time won’t work, it’s too inconsistent! Sometimes it does (the output says it) but sometimes not.

I have tried using .Changed, :GetPropertyChangedSignal() and loops on the checks, but none seemed to work.

I also have tried adding a delay which did not solve the issue. Any help is appreciated!

					Part:GetPropertyChangedSignal("Position"):Connect(function()
						if Touched == false then
								Check()
					end
					Pos = Part.Position
				end)
					local function Check()
						local RaycastParam = RaycastParams.new()
						RaycastParam.FilterDescendantsInstances = IgnoreStuff
					local StartingPosition = Pos
					local Mag = (Pos - Part.Position).magnitude
					local StartingPosition2 = Part.Position
					local Raycast = workspace:Raycast(StartingPosition,(StartingPosition2 - StartingPosition) * 100,RaycastParam)
						if Raycast and Raycast.Instance:IsA("BasePart") and Raycast.Instance.Name ~= "Ignore" and not Raycast.Instance:FindFirstChild("Ignore") or Raycast and Raycast.Instance:IsA("Part") and Raycast.Instance.Name ~= "Ignore" and not Raycast.Instance:FindFirstChild("Ignore") then
							print("RaycastFound")
							Touched = true
						Tween:Cancel()
							Explode(Raycast.Instance,CFrame.new(Raycast.Position))
						end
					end

1 Like

Why didn’ t you use .Touched? What happened when you used it? If you use Raycast then you have to skip frames or it ill lag so why not using an event that runs only when it’ s supposed to?

I have not used .Touched because since the projectile goes so fast, it skips frames and does not land (Sorry, i’ll include the footage real quick)

BasePart:GetPropertyChangedSignal(“Position”) or BasePart.Changed are both inconsistent for checking changes in the position. You should instead base it on an action, like if a push force gets inserted into the object, then you’ll know it’s moving.

As I already said, I tried loops too which should not affect consistency. So I don’t think it is that either. The thing is, I store the previous position and the current then raycast, and should not skip any stud.

1 Like

You should try something like FastCast then. It’s a projectile prediction system and it’s always accurate.

Turns out all this time it was an issue related to the blacklisting of the raycast

1 Like

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