How do I inverse raycast in 2D ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zenbobilly

Is there a way to cast a ray to the first point of non-contact with a specified object(s) with the assumption that the cast is originating inside one of the collider(s) of the specified object(s) ? I know you can move along the vector manually and use intersect_point_on_canvas (), but is there a better way to do this ?

I don’t understand. Could you elaborate please?

“cast a ray to the first point of non-contact with a specified
object(s)”

What do you mean a point of “non-contact”?

DaddyMonster | 2022-08-25 22:22

I don’t care about the normal, I just want to find the edge of the collider from the inside of it.

zenbobilly | 2022-08-26 01:05

“I just want to find the edge of the collider from the inside of it.”

I don’t know what this means. Maybe the vector from the collision object’s origin to the ray intersection point in global space? Or maybe something completely different.

I’m sorry, the problem is not clear enough for me to be able to answer, I’d just be guessing at what you’re looking for.

DaddyMonster | 2022-08-26 13:04

The situation is this, I have a line segment where both ends are within different collision shapes and I want to adjust the line segment so that it excludes those collision areas. I can’t raycast from AB or vice versa because a raycast within a collider that you are testing for is invalid. Therein lies the problem.

zenbobilly | 2022-08-26 13:44