By using Physics.Raycast in Unity, we can get hit information easily with the point, normal, collider name... But how can I get the "point" where ray go out of the collider?
Many thanks for your time thinking about this problem.
By using Physics.Raycast in Unity, we can get hit information easily with the point, normal, collider name... But how can I get the "point" where ray go out of the collider?
Many thanks for your time thinking about this problem.
You could try casting a reverse ray only on the collider that has been hit so that you can determine where the ray enters from the back? The code below might work.
RaycastHit firstHit;
Ray firstRay = new Ray (origin, direction);
Physics.Raycast (firstRay, out firstHit, distance);
Vector3 reverseOrigin = firstRay.origin + (firstRay.direction * distance);
RaycastHit reverseHit;
Ray reverseRay = new Ray (reverseOrigin, (firstRay.direction * -1));
firstHit.collider.Raycast (reverseRay, out reverseHit, distance);