コード例 #1
0
    Godot.Vector2 getFlyableLaunchForce()
    {
        GeoLib.Vector2 mousePos   = new GeoLib.Vector2(flyable.GetGlobalMousePosition().x, flyable.GetGlobalMousePosition().y);
        GeoLib.Vector2 flyablePos = new GeoLib.Vector2(flyable.Position.x, flyable.Position.y);

        MathLine strikeLine = new MathLine(mousePos, flyablePos);
        double   angle      = strikeLine.GetAcuteAngle();

        float xForce = Flyable.FORCE * (float)Math.Cos(angle);
        float yForce = Flyable.FORCE * (float)Math.Sin(angle);

        Godot.Vector2 hitForce = new Godot.Vector2(xForce, yForce);

        if (mousePos.X < flyablePos.X)
        {
            hitForce *= -1;
        }

        return(hitForce);
    }