This guide assumes Godot Mono 3.2.3 and JetBrains Rider 2020.3 on Mac. I got F# working in Godot by following this guide which was very helpful, and the current post mainly restates most of what that author was saying with some updates and with some additional screenshots - mostly for my own benefit and my own forgetfulness and because a few things have changed since that article was written. If you find this helfpul, please give the blog linked above the credit and not me.

I intend to keep this guide up-to-date as I notice any changes to the setup (Godot doesn't officially support F#, so there will likely always be a minor amount of finagling required).

Step 1

Create your Godot project using mono. Add a scene, then right click the scene and select "Attach Script." Select C# as the language. By adding C#, Godot will automatically add a .sln file.

Step 2

Open you IDE (Rider in my case), open the solution. Right click on the solution in your file explorer, go to "Add", and then "New Project."

In the next screen, name your F# project. I go for a naming convention that encourages modularity. For example, here I named the project "FSharp.Scripting," but later may add something like "FSharp.Helpers."

Select the following options: For type select Class Library, for Language select F# and for Framework select .Net Framework v4.7.2.

Click "Create."

Step 3

Once the new project is created, right click on "dependencies" and then click "Add Reference." In the search bar, type "godot" and then check "GodotSharp" in the filtered list. Click "Add".

Step 4

Now right-click on "dependencies" in the C# project that was created by Godot when you added your C# script. Click "Add Reference" just like you did for the F# dependencies in the last step. In the search bar, start typing in what you named your F# project. In my case it was "FSharp.Scripting". Click "Add".

Step 5

Create a new F# file in the root of your FSharp.Scripting project. Name it the the same thing as the file that Godot created for your node's script. If it created "Player.cs", this will be "Player.fs". Don't get creative with the naming here, because as the project grows you'll want to easily determine what F# file goes to which node.

In the file, put the following (of course, substitute "Player" for your node's name and inherit the proper node type):

namespace FSharp.Player

open Godot

type PlayerFs() =
    inherit Area2D()

    override this._Ready() =
        GD.Print("Hello from F#!")

Then we'll update the C# file so that it just extends the F# class.

using FSharp.Player;

public class Player : PlayerFs
{}

Step 6

Now go back to Godot and click the "Play" button in the upper right. Godot will play the scene you've created, which has the C# script attached to it. You should see the message from the PlayerFs class.

What's next?

If you intend to do most of your development in F#, your process for creating scripts will likely consist of creating the C# class for each node and extending it to use an F# class. Or you can mix and match as you see fit (you can even use GDScript for some scripts and C#/F# for others).