Is it possible to measure distance's between raycast intersections?

14812-untitled-1.jpg

Is it possible to measure the distance between point a and point b. The redline is a raycast. hit.point can be used to find point a but what about point b?

Hi, raycast can hit only forward faces. You could cast another ray backwards, or you could create another collider and place it from side a, cast two rays, one will get the hit_b.point, other hit_a.point (ignoring collision with the first collider b), then you can measure distance between these two points.

Did we forget about raycastall?

var dist:float;
var hits: RaycastHit[];
	hits = Physics.RaycastAll(transform.position, transform.forward, 100.0F);
	if(hits.Length>1) {dist = Vector3.Distance(hits[1].point, hits[0].point);}