var wall_finder[3];
var wall_result;
vec_rotate(wall_finder.x,my.pan); //rotate trace to players rotation
vec_add(wall_finder.x,vector(my.x,my.y,my.z)); // keep trace to player as he moves
wall_result = c_trace(my.x,wall_finder.x,ignore_me | ignore_passable); //find distance to wall
This code works for me to find distance of player from a wall. Also remember the trace needs to be rotated to the players facing direction.