Hello,
have a question regarding Raycast hit distance.
I orignally had an issue and found another thread mentioning we should normalize the direction vector.
Without normalized direction I have values for hit.distance within the maxdistance value (for maxdistance 5, I had values like 4.7, 4.9, …)
With normalized direction I have values between 0 and 1.
It is strange for me that the direction has such an influence on the distance.
I suppose that if I multiply maxdistance by the normalized direction I will get the actual distance ?
Additionally, in both cases, the object distance (calculated with Vector3.Distance), give values such as 22.8, 23.7 …).
So object distance has nothing to do with hit.distance.
Why ?
if (Physics.Raycast(transform.position, Vector3.Normalize(SeenObject.transform.position - transform.position), out hit, SightRadius, WhatToPursuit))
{
Debug.Log("vector distance " + Vector3.Distance(transform.position, SeenObject.transform.position - transform.position));
Debug.Log("seenobject distance " + hit.distance);
}