Hey everyone,
I’m working on a pixel art game using raycasts, but I’ve run into an issue. When moving the mouse quickly across the screen, the raycast seems to skip pixels, as shown in this video:
I’m already using RenderStepped
, so I’m not sure how to make it more accurate. Here’s my current code:
rs.RenderStepped:Connect(function(dt)
if not InGame.Value or not clicked then return end
local raycastParams = RaycastParams.new()
local raycast = workspace:Raycast(mouse.UnitRay.Origin, mouse.UnitRay.Direction * 1000, raycastParams)
if not raycast then return end
local rayInstance = raycast.Instance
if rayInstance.Parent.Name ~= "PixelGrid" then return end
rayInstance.Color = Color3.new(0, 0, 0)
end)
I’m guessing the issue happens because the mouse moves too far between frames, causing some pixels to be missed. Does anyone know a better way to ensure all pixels get updated, even when moving the mouse quickly?
Any help would be greatly appreciated! Thanks