Thanks, that make sence. I forgot to add in the second vector the my.position so I think that the trace was form the center (green lines) instead of from the entity.
Now I change the script as follows (again only the horizontal moving is showing)
Code:
// trace to the right
vec_set(trace_right,vector(my.x+scan_dist,my.y,my.z));
dist_right=c_trace(my.x,trace_right.x,ignore_me|use_polygon);
if(dist_right==0 && move_left==0)
{
c_move(my,vector(8,0,0),nullvector,ignore_me|ignore_maps);
// second trace after moving
dist_right=c_trace(my.x,trace_right.x,ignore_me|use_polygon);
if(dist_right==0)
{
move_right=1;
move_left=0;
}
else
{
move_right=0;
move_left=1;
}
}
else
{
// trace to the left
beep();
vec_set(trace_left,vector(my.x-scan_dist,my.y,my.z));
dist_left=c_trace(my.x,trace_left.x,ignore_me|use_polygon);
if(dist_left==0 && move_right==0)
{
c_move(my,vector(-8,0,0),nullvector,ignore_me|ignore_maps);
// second trace after moving
beep();
dist_left=c_trace(my.x,trace_left.x,ignore_me|use_polygon);
if(dist_left==0)
{
move_right=0;
move_left=1;
}
else
{
move_right=1;
move_left=0;
}
}
}
Now I can move the slider to the right, but when it hits the barrier, I only hear the first beep and the slider will not move to the left.
What am I doing wrong here? Please help?