Unity – How to make things see where they’re going

While developing a game, I wanted to enable characters to “see” where they’re going; that is, to tell them what they’re about to stumble into, without using colliders. The answer was to cast a Ray, angled slightly downward,  in front of the character, so he can “see” if he’s about to walk into a tree, or a river, before it happens.

The image at the top of the post shows a character (dog) casting a Ray (yellow line) downward in front of him, through the floor.

But the Ray intersects a tree and points the object out to him (red line).


 

I do this like so:

InterServer Web Hosting and VPS