HI all,
I’m doing a BoxCastAll into my scene and need to know whether it has collided with horizontal ground or vertical wall. Both the ground and the wall are the same object (a custom 3D modeled environment) and are using a single mesh collider. The ground is not perfectly horizontal and the wall is not perfectly vertical.
I thought I could solve this using a dot product between the collision normal and an Up vector, but the collision normal returned by BoxCastAll seems really unreliable.
Here you can see the result of a box cast from the camera into the scene, colliding with a default Unity plane so it should be as flat and horizontal as it can be:
The long white line passing through the red X is the ray along which the box is cast.
The red X is the point the ray intersects the ground plain.
The blue X is the contact point returned by BoxCastAll
The white line coming from the blue X is the collision normal reported by BoxCastAll
Because the contact point is not centered on the face of the box, I do some conversion to get where the box should be at the moment of collision, that’s what the green X is and the yellow box is the box placed at that location.
Note the normal is not straight up, it’s at an angle, even though it’s colliding with a flat plane.
I have this boxcast following the mouse and as I move the mouse around the normal fluctuates wildly, sometimes it’s straight up, often its at a weird angle.
Anyone know why this is?
When I drag the box over a wall, I also get angled normals and can’t tell the difference between whether its angled because of a slightly slopped wall, or a weird normal returned by the ground
I need to somehow determine the steepness of the surface the box is on. Anyone know a solution?

