I'm not a C-Script programer so, basically, this is what you need to do in Lite-C laugh :

Code:
// Calculate rotation
VECTOR *front = vector(32, 0, 0);   // Fron location
// Rotate front relative to the entity
vec_rotate(front, vector(my.pan, 0, 0)); // Take into account only pan angle
		
VECTOR trace_pos;   // The trace position
		
// Do a first trace for  the front legs
vec_set(trace_pos, my.x);
vec_add(trace_pos, front);
var front_trace = c_trace (trace_pos, vector(trace_pos.x, trace_pos.y, trace_pos.z - 10000), IGNORE_ME | IGNORE_PASSABLE);
				
		
// Do a second trace for the rear legs
VECTOR *rear = vector(0, 0, 0);
vec_set(rear, front);

// reverse x direction
rear.x *= -1;
vec_set(trace_pos, my.x);
vec_add(trace_pos, rear);
var rear_trace = c_trace (trace_pos, vector(trace_pos.x, trace_pos.y, trace_pos.z - 10000), IGNORE_ME | IGNORE_PASSABLE);
		
// Calculate the tilt based on the traces pos
var delta = front_trace - rear_trace;
var dist = 64; // 64 (size of the animal)
var tilt_angle = -atan2v(delta, dist);
my.tilt = tilt_angle;