Exporting Godot Variables in F#
In Godot, it's convenient to export variables so that they can be updated via the Inspector tab. Doing so in C# looks like this:
using Godot;
public class Player : Area2D
{
[Export] public float Speed = 2f;
public override void _Ready()
{}
public override void _Process(float delta)
{}
}
Here the Speed
variable is exported via the Export
attribute that Godot provides. Doing this in F# looks like this:
open Godot
type PlayerFs() =
inherit Area2D()
[<Export>]
let mutable Speed = 2.00f
override this._Ready() =
ignore 0
override this._Process(delta) =
ignore 0
The same attribute is used, but the key is the mutable
keyword. If mutable
is not specified, the variable will not even show up in the Inspector tab.