Posted By: Sajeth
smooth(camera.pan) - 10/05/10 18:56
Hello folks,
how can I smooth a camera.pan value with the smooth function without getting those twists as soon as the value changes from -180 to 180 and vice versa? Tried different things, including a reset of the smooth function on each "big jump", but this has the side effects of causing camera "hickups".
Regards
Posted By: MasterQ32
Re: smooth(camera.pan) - 10/05/10 18:57
in which way do you control your camera.pan?
Posted By: Sajeth
Re: smooth(camera.pan) - 10/05/10 18:59
Always turned towards a specific actor, set by vec_to_angle
If theres no feasible way, I'll have to find a workaround...
Posted By: Superku
Re: smooth(camera.pan) - 10/05/10 19:05
camera.pan += ang(target_pan-camera.pan)*time_step;
Since I discovered this method I use it in every code to smooth positions and angles. If the camera turns to fast, use the following code:
camera.pan += clamp(ang(target_pan-camera.pan),-15,15)*time_step;
Posted By: Sajeth
Re: smooth(camera.pan) - 10/05/10 19:34
if(abs(camera.pan-oldcampan)>100)
{
if(camera.pan>oldcampan)
oldcampan+=360;
else
oldcampan-=360;
}
camera.pan = camera.pan * (1-CAMERASMOOTHFAC) + oldcampan * CAMERASMOOTHFAC;
oldcampan=camera.pan;
Probably the most dirty way to pull this off...
But works just fine.
Posted By: Superku
Re: smooth(camera.pan) - 10/05/10 19:39
Ehm... did you try my code?
Posted By: Sajeth
Re: smooth(camera.pan) - 10/05/10 19:43
Ehm... did you try my code?
Yep - and thanks for that - but yours reacts pretty choppy, and I figured easiest way going would be to kind of recode the smooth()-function. Thanks anyways
Posted By: Superku
Re: smooth(camera.pan) - 10/05/10 19:51
"but yours reacts pretty choppy"
No, it doesn't. Tell me what's wrong with it!
Posted By: Sajeth
Re: smooth(camera.pan) - 10/06/10 06:21
Yes, for some reason it moves laggy as soon as the fps drop under 60. I guess with slower movement it would work fine, but not in my case.
Posted By: Superku
Re: smooth(camera.pan) - 10/06/10 12:02
Hm... The reason must be your "target_pan", because my game still runs smooth at 30fps or less.
Posted By: Sajeth
Re: smooth(camera.pan) - 10/06/10 14:13