- Home /
Physics.Raycast not hit sometimes
Hi, I have a very strange Raycast behaviour. Theare are 2 moving objects in my game. I use raycast in the Update method to find out if the second object is near. But sometimes raycast return false in obviously "true" situations. Can somebody help me to fix this issue? Thanks a lot!
The white line visualize the raycast. Green lines - box collider.
// Returns false, but should be true
var middle = Physics.Raycast(Car.SensorPointRight.position, Car.CarObject.right, out middleHitsInfo, (DistanceBetweenPaths - _carColliderOffset));
if (IsUserCar)
DebugHepler.Ray(Car.SensorPointRight.position, Car.CarObject.right * (DistanceBetweenPaths - _carColliderOffset), middle ? Color.red : Color.white);
Comment