making the view slow down then stop[SOLVED]

fxokz

Member
Im trying to make it so that when a portal is created the view moves towards the portal fast at first but gets slower the closer it gets. Ive sort of achieved this effect but it still doesnt feel like the speed is decreasing enough. code;

Code:
if instance_exists(obj_portal)
{
    dir = point_direction(x, y, obj_portal.x, obj_portal.y);
    dist = point_distance(x, y, obj_portal.x, obj_portal.y);
    if (dist) < 5
    {
        x = obj_portal.x;
        y = obj_portal.y;
    } else {
        hspeed = 20 * dcos(dir)/5;
        vspeed = -20 * dsin(dir)/5;
    }
}
Do you guys know how i can make it start off faster but decrease right after?
 
M

Maximus

Guest
use some fraction of the dist instead of the '20'

edit and get rid of the '/5'
 

fxokz

Member
use some fraction of the dist instead of the '20'

edit and get rid of the '/5'
you are gonna have to hold my hand on this one because i tried using dist but it just made the camera spaz out

updated code
Code:
if instance_exists(obj_portal)
{
    dir = point_direction(x, y, obj_portal.x, obj_portal.y);
    dist = point_distance(x, y, obj_portal.x, obj_portal.y);
    if (dist) < 10
    {
        x = obj_portal.x;
        y = obj_portal.y;
    } else {
        hspeed = (dist*0.01) * dcos(dir);
        vspeed = (dist*0.01) * dsin(dir);
    }
}
 
Last edited:
M

Maximus

Guest
Code:
if instance_exists(obj_portal)
{
    dir = point_direction(x, y, obj_portal.x, obj_portal.y);
    dist = point_distance(x, y, obj_portal.x, obj_portal.y);
    if (dist) < 5
    {
        x = obj_portal.x;
        y = obj_portal.y;
    } else {
        hspeed =  0.2 * dist * dcos(dir);
        vspeed = -0.2 * dist * dsin(dir);
    }
}
else
{
    // if the camera has any other movement code, move it here. (that might have been the 'spaz' you were seeing)
}
 
Top