How do you find parts that are near a diagonal line using .magnitude?

I want to find parts that are near a diagonal line like this:

1 Like

You could probably use SphereCast (unsure if it’s fully out) then you could make the size as big as you need; then cast as usual (startpos to endpos).

Would that also give me the distance from the line like .magnitude does?

Uhhh I’m not sure, I’ll edit this reply when I read the documentation.

Here’s the documentation for reference:

Seems like it does have a distance property but you might have to try it yourself

I would define a Ray using an origin and a direction (with a unit length), then loop through each part and call ray:Distance(part.position) to find the closest parts.

Alternatively you could implement the same function yourself with dot product.

4 Likes

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