The bug
The maxDistance field in BlockRaycastOptions as used in some scripting APIs like dimension.getBlockFromRay limits the distance that the raycast will travel to find a block before giving up and returning undefined.
It works correctly when the provided (normalized) direction vector only has one of x, y, or z set to a non-zero value. However, if the vector does cross multiple axes, the raycast does not travel far enough before giving up. It’s not clear exactly what factor determines the actual distance traveled, but it is always less than the provided maxDistance.
How to reproduce
Download and open the attached world. It contains a script that raycasts in all directions. Red spheres appear indicating the direction of each raycast, extending to a maximum distance of 5.0. A green sphere appears when
getBlockFromRayfound a hit.Walk around the glass circle and observe when the green circles appear.
Expected behavior
Anytime the red circles intersect with the glass, a green circle should appear indicating a raycast with that same maxDistance found the relevant block.
Observed behavior
In the cardinal directions, this occurs. In the other directions, the green circle does not appear until the red circles have deeply intersected with the glass, indicating that the raycast did not travel the distance specified.
Notes
The relevant script file has been attached for convenience.
Attachments
Comments 0
No comments.