I've got this piece of code for the camera on a third person view

Code:
if(c_trace(my.x,camera.x,IGNORE_ME | IGNORE_PASSENTS | IGNORE_MAPS | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_CONTENT) > 0)
{
	vec_set(camera.x,target);
	vec_add(camera.x,normal);
}
else
{
	camera.x = me.x - camera_distance * cos(me.pan); 
	camera.y = me.y - camera_distance * sin(me.pan); 
	camera.z = me.z + camera_distance;
	camera.tilt = -(camera_distance/3);
	camera.pan = me.pan;
}



But when I test it and I put the player in front of a wall I get a flickering effect, it's like the camera is going forward and backward like if it is executing the if statement and right after that it runs the else statement, what do you think is the problem here?

Here is a gif that illustrates my problem:



Last edited by Theil; 10/14/11 13:32.