So I’m aware the worksapce has a command named FindPartsInRay and FindPartsInRegion3
I know what a Region3 is, but I do not know what a ray is
So I’m aware the worksapce has a command named FindPartsInRay and FindPartsInRegion3
I know what a Region3 is, but I do not know what a ray is
It’s a line in 3D space defined by an origin point and a direction vector.
http://robloxdev.com/articles/Raycasting
http://robloxdev.com/api-reference/datatype/Ray
you probably first learned about them in math class when you were really young, it’s a line that extends infinitely in one direction, coming from a single point, commonly drawn like this
(note: they’re not infinite in roblox)
Are you familiar with the concept of a point?
Like on a coordinate plane, I can define a point (like the point (2,3) is 2 units to the right on the X-Axis, and 3 units up on the Y-Axis)
Now, a ray (atleast in roblox) is like a point; But, it also has some other special information: The direction of the ray, and (specifically in roblox), the magnitude (also known as length) of the ray.
Think of it like a hand of an old fashioned analog clock. Each hand is like a ray that Starts from the middle of the clock, and ends at the outer edge of the clock. The magnitude of the ray would be the distance from the center to the edge.
Here is a quick graphic I whipped up that might show it better.
When I said ‘ray’, I mean the DataType
I understand the basic math behind rays
Rays have two pieces of information: a start point, and a direction vector. The direction vector is not a unit vector, it’s the length of the ray. When you cast a ray via one of the workspace functions, you can determine what part(s) are in the way of the ray, starting from its origin.