Page 1 of 1

Smooth view :S

PostPosted: Tue Jan 29, 2008 8:58 pm
by alkoh002
Hi, (duh! i have all these questions, which the answer is really simple.. :S) how can i make so the view follows its parent "smoothly" and not the exact movement by the parent?

Re: Smooth view :S

PostPosted: Wed Jan 30, 2008 8:37 am
by Kalladdolf
there is a turtorial just about this very thing:
you'll find it in Game Editor.
help -> game stuff -> make view follow player (2)
it's really handy.

Re: Smooth view :S

PostPosted: Wed Jan 30, 2008 11:39 am
by DilloDude
This works well for me:
Code: Select all
int refx = x + 160;//change to half the width
int refy = y + 120;//change to half the height

if (unpaused)//use whatever conditionals to limit
{
    double dir;
    double spd;

    dir = direction(refx, refy, player.x, player.y);
    spd = distance(refx, refy, player.x, player.y) * .1;//adjust this value to suit
 
    if (spd > .2)//adjust this too
    {
        x += xdist(dir, spd);
        y += ydist(dir, spd);
    }
}

You'll need the xdist and ydist functions in global code:
Code: Select all
double xdist(double angsize, double dist)
{
    return cos(degtorad(angsize)) * dist;
}


double ydist(double angsize, double dist)
{
    return sin(degtorad(angsize)) * -dist;
}

Re: Smooth view :S

PostPosted: Wed Jan 30, 2008 6:10 pm
by alkoh002
Thanks people! :D