Hello,
I wrote script for rotating camera around certain point with certain radius while camera is still looking at that point, which can be an entity:
long radius;
long posx=-800;
long posy=0;
var up=1;
var speed=20*time_step;
vec_to_angle(camera.pan,vec_diff(NULL,some_entity.x,camera.x));
if(key_cul)
{
if(up==1)
{
if(posx<=radius)
{
posx+=speed;
posy=sqrt((radius*radius)-(posx*posx));
}
if(posx>=radius)
{
up=0;
}
}
if(up==0)
{
if(posx>=-radius)
{
posx-=speed;
posy=-sqrt((radius*radius)-(posx*posx));
}
if(posx<=-radius)
{
up=1;
}
}
It works, however the rotation speed is not linear (because sqrt function is not linear). The questin is, how could I achieve linear rotation speed? Or is there any function (lite-c) to achieve such rotation of camera?
It should work similary as 3D RPG camera with free rotation mode
(eg Sacred 2, Dungeon Siege...etc)