scrDirection

The object will move from it's current direction to the new direction

 Script

///Direction Change

/* finds the smallest distance between its current direction and new direction and starts moving towards it
to use this apply values to these variables:
dir = (boolean) 
    enables/disables the script
dir_val = (double)
    the final direction the object will be
dir_dev = (double)
    the rate at which it changes to dir_val
*/
if (dir) {
    var dif = angle_difference(direction,dir_new);
    var inc = abs(dir_dev);
    var flag = false;
    
    show_debug_message("(ID,dir,dir_new,dif,inc) - ("+string(number)+","+string(direction)+","+string(dir_new)+","+string(dif)+","+string(inc)+")");
    
    if dif < 0 { // if negative
        direction += dir_dev;
        if angle_difference(direction,dir_new) > 0 {
            flag = true;
        }
    } else { // if positive
        direction -= dir_dev;
        if angle_difference(direction,dir_new) < 0 {
            flag = true;
        }
    }
    
    if (flag) { // we there
        direction = dir_new;
        dir = false;
    }
}