3rd person camera spring

Started by
11 comments, last by Staffan E 18 years, 7 months ago
I think you could extend the model to handle such cases if you replace

(θcar - θcamera)

in the above expression with

(absmin( φ1, φ2 ))

where

φ1 = θcar - θcamera

and

φ2 = θcar - θcamera - (360 * sign(θcar - θcamera)),

and where absmin() is a function that picks out the argument with the smallest absolute value and sign() is a function that returns the sign of the argument (1 or -1).

This should if I'm not mistaken pick out the closest way around the circle. For example if θcar = 179 and θcamera = -179 the result of this expression would be -2, making the camera strive for -181 which in turn will be mapped to 179; the car's direction.
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
Advertisement
staaf, it's working grrreat! You are a math genius! All I had to do was clamp the values of theta_cam so that they didn't go beyond 360 and -360 degrees. Works like a charm! Thanks a lot for your help!

rating++
I'm glad it worked out for you. Now that I got to think about it I noted that directed angles can be a pain. Perhaps I should try to make an effort some time to wrap up this functionality in some kind of toolset to handle directed angles in a controlled way.

Anyway, see you around.
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker

This topic is closed to new replies.

Advertisement