Ok I see I should have commented it a little. Have a look at the test code that I've written earlier:

Code:
var i;
var target_tilt = 0;
var target_counter = 48;
var camera_tilt_speed = 0;

[...]

target_counter = maxv(target_counter-time_step,0);
if(!target_counter)
{
	target_tilt = -35-target_tilt; // switch between 0 and -35
	target_counter = 64; // every 4 seconds
}

i = ang(target_tilt - camera.tilt)*0.25;
camera_tilt_speed = minv(camera_tilt_speed+0.25*time_step,minv(abs(i),5));
camera.tilt += clamp(i,-camera_tilt_speed,camera_tilt_speed)*time_step;


This code is useful when target_tilt only changes every now and then, f.i. in a cut scene or something like that. The line

camera_tilt_speed = minv(camera_tilt_speed+0.25*time_step,minv(abs(i),5));

makes sure that the change in camera starts smoothly, not at full speed, in particular the minv(abs(i),5) "resets" the speed value to a low value without an if clause when the target angle is close.

Depending on the actual purpose of your code (I'm not really sure what it will be used for) it may be a better choice to use one of the two other approaches, f.i. when the target angles change quickly.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends