Since the old raycast is deprecated, what's the "ray" datatype still useful for?

Apologies if this is a silly question.
So as some of us may know, Roblox has deprecated the old raycast function many years ago.

However the ray data type still remains in the documentation, completely untouched by deprecation.

I tried asking Roblox’ AI assistant but it only provides incorrect information on any of the questions I asked.

So what’s this “ray” data type still useful for if it isn’t for raycasting?

I can only think of one really useful usecase which is the ClosestToPoint function.
But I feel like you can also write this function yourself with a little bit of math?

(Still glad it’s there though, time saver.)

But I wish to know and learn more about other possible usecases for this.
It’s no longer really deemed useful for raycasting since it has been replaced with a better raycast.

But it is still there for a reason, right?

It’s still there to provide support for older games that are not up-to-date with the new method. Same goes for all other deprecated features. For example, Model:BreakJoints() still works but it is not recommended for using.

The Ray datatype is useful for representing ray data without performing a cast. Engine APIs that are internally raycasts still provide a Ray object for developer use where you can use the properties of the Ray to perform your work. An example is ViewportPointToRay.

The only thing that’s deprecated is the mass of raycast methods in favour of a single method that takes RaycastParams to configure the way the raycast is performed. You can otherwise still see the Ray datatype in use across a couple of APIs or construct one yourself.

1 Like

OP meant that the Ray datatype is not marked as deprecated in the official documentation.

2 Likes

I was sort of figuring out what else the ray data type was useful for.
I’ve considered using it’s ClosestToPoint function.

So the thing is, I figured that in a game where weapons fire projectiles and lasers, I can probably check if the player is even close enough to the projectile’s path of traversal to determine is visualizing it is even necessary.

Using this point function I can check which part of the projectile’s path is closest to the player, then check if it’s outside the render distance, which if it is then I don’t have to visualize it.

Other usecases I’ve found for the ClosestToPoint function is that it could potentially be used for calculating triangles?

I’ve wanted to learn how to construct triangle terrain with wedge parts for a while but one thing I got stuck on was figuring out where two wedges should face each other on the longest side of the triangle.

Figured the ClosestToPoint function might help with finding the closest point to the triangle’s “tent” as I’d like to call it, after that I only need to size and rotate the wedge parts correctly me thinks.

But that’s about as far as my brain gets me right now.