예제 #1
0
    public static void moveShipToPosition(Formation formation, Vector3 target, float maxSpeed)
    {
        var targetRotation = Helper.rotationTowards(formation.ship.transform, target);
        formation.ship.transform.rotation = Quaternion.Slerp(formation.ship.transform.rotation, targetRotation, 0.03f);

        var distance = Helper.getDistance(formation.ship.transform, target);

        var isOutOfRange = distance > maxSpeed/10;
        formation.applyMovement(new Vector3(), new Vector3(), new Vector3(0, 0, isOutOfRange ? 1.1f*maxSpeed : 3*maxSpeed / 4));
    }