Softer(?) Raycast for Build Tool [SOLVED]

I am trying to remake the build tool in games like BEF (Big Evil Faces) and A Silent Town. I basically have it down but Im having issues with raycasting. It seems too strict and whenever I try building on anything the Raycast has a high chance of hitting the target, making building on objects much more difficult than it should be.
Is there a way to make the raycast softer or a way to offset it maybe towards the player so its not directly on the object?

You can offset the part’s postition by half its size in the direction of the raycast’s normal vector (its face direction)

partOffset = newPart.Size/2 :: Vector3
newPart.CFrame = goalCFrame + CFrame.new(castInstanceNormal * partOffset)

Edit: This is a very, very rough outline based on my limited experience with similar issues, the math will most definitely need some adjusting lol

1 Like

Oh, there’s also shapecasting which can help detect when more complex shapes may be about to collide with something beforehand, which can help reduce spamming regular raycasts

another link about more complex shapecasts

And another

1 Like

I got it working. I used 8 raycasts slightly offset in a different direction to see if there was any possibility that it could be valid. This shouldn’t be much of an issue since its only 8 per frame and the server only has to deal with 8 raycasts per player request to place an object. Heres the final result :slight_smile: