function TurnToAngle(id, speed, angle){
    let current_angle = ObjMove_GetAngle(id);
    let target_angle = angle;
    let adist = AngularDistance(current_angle, target_angle);

    if(absolute(adist) < speed){
        ObjMove_SetAngle(id, target_angle);
    }
    else {
        if(adist > 0){
            ObjMove_SetAngle(id, ObjMove_GetAngle(id)+speed);
        }
        else if(adist < 0){
            ObjMove_SetAngle(id, ObjMove_GetAngle(id)-speed);
        }
    }
}

function TurnToPoint(id, speed, PointX, PointY){
    let current_angle = ObjMove_GetAngle(id);
    let target_angle = atan2(PointY-ObjMove_GetY(id), PointX-ObjMove_GetY(id));
    let adist = AngularDistance(current_angle, target_angle);

    if(absolute(adist) < speed){
        ObjMove_SetAngle(id, target_angle);
    }
    else {
        if(adist > 0){
            ObjMove_SetAngle(id, ObjMove_GetAngle(id)+speed);
        }
        else if(adist < 0){
            ObjMove_SetAngle(id, ObjMove_GetAngle(id)-speed);
        }
    }
}