Raycasting skips parts

It only happens when the direction is on an axis ((1,0,0), (-1,0,0), etc) but in a lot of places the ray doesn’t hit parts that it is supposed to hit.

I can’t repro. Is there a place file that might help?

It may only happen very far away from 0,0,0. I made a system of lasers that opens and close gates, and the lasers count to 10 in binary and trigger a digit to change each time one gets to 10. When the last gets to 10, 6 is added to all of them. It’s simulated really far out, though.

How far out are we talking? I do know that computers aren’t infinitely accurate with floating point calculations, and that the accuracy of these calculations drops as the numbers involved become larger.

More than a few thousand studs away.

You should be writing your own raycast function, that can work on specific data, what exactly are you doing? also, if the origin of the ray is inside of the Part, the ray won’t hit the part, and as long as distane is smaller than 5k away, you should be good, it gets really bad at about 20kish, in my tests

I would expect these sorts of things to begin happening at about 15 000 studs out. Are you this far out? Do you need to be this far out?

It’s a building game and players get private bases that are separated in 8 directions and are set further out when there are more than 8 players. It would be nice, if this is the cause, if anyone can think of a way to keep the bases closer without allowing other players to copy things from far away, since the copy and move tools are C-sided and their Lua equivalents don’t drag the same way where the distance at which they still function can be restricted.

use a magnitude function, and don’t move the part if it exceeds distance, also, you can make a lua move tool exactly like roblox’s, with r and t working the same :slight_smile:

basically:
function ClickedOrDragged()
if (Part.Position-Player’sBase.Position).magnitude < DIstanceLimit then
–dostuff
end
end

https://developer.roblox.com/en-us/api-reference/function/WorldRoot/Raycast

The maximum length of the direction vector from the origin point is 5,000 studs, so if the casted raycast exceeds this limit then it’ll return nil instead of the expected RaycastResult object.