Game Development Community

Differentiating between Horizontal and Vertical Surfaces...

by Clark Kromenaker · in Torque Game Engine · 04/02/2006 (11:54 am) · 2 replies

Hi,

I'm using some code that lets the user click and the character moves to said position. However, when the user clicks on a wall or other vertical surface, the character will run straight into the wall. So, I was wondering if it's possible to check whether a clicked surface is horizontal or vertical so I can weed out the clicks on walls.

#1
04/02/2006 (11:59 am)
I believe a raycast returns the normal to the surface which the ray hit.
just look at the Z component of the normal.
if it's one, the surface is horizontal.
if it's zero, the surface is vertical.
somewhere in between will be some threshhold you can use.
eg
if (normal.Z > myThreshhold)
   // then the surface is horizontal enough.
else
   // it's a wall or something else vertical.
#2
04/02/2006 (1:01 pm)
Thanks, I'll take a look at that.