Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be πŸ“–

OpenFairWay Golf Physics Simulator Library

An asset by jesseincode
The page banner background of a mountain and forest
OpenFairWay Golf Physics Simulator Library hero image

Quick Information

0 ratings
OpenFairWay Golf Physics Simulator Library icon image
jesseincode
OpenFairWay Golf Physics Simulator Library

An open source golf physics simulator library.- v1.0.2 - Major Bug fixes in physics. Y clamp down fix. Lets ball react more natural using Jolt physics. - v1.0.1 - Supports logging control (e.g. error, info, verbose)- Asset only downloads addon, nothing else. - v1.0.0 - First Publish (working physics library with docs)

Supported Engine Version
4.5
Version String
1.0.2
License Version
MIT
Support Level
community
Modified Date
5 days ago
Git URL
Issue URL

OpenFairway Physics

Realistic golf ball physics engine for Godot 4.5+ (.NET/C#). Provides force, torque, bounce, and surface interaction calculations usable from both C# and GDScript.

README CI/CD Pipeline README License: MIT README .NET 8.0 README Godot 4.5+

Github

  • Do not ever commit code.

Features

  • Aerodynamic drag and Magnus lift from wind-tunnel polynomial fits
  • Bounce model with spin-dependent COR and tangential retention (Penner)
  • Surface presets for fairway, rough, soft, and firm conditions
  • Spin-based ground friction with "check up" behavior for high-spin shots
  • Launch monitor spin parsing (BackSpin/SideSpin or TotalSpin/SpinAxis)
  • Headless shot simulation via PhysicsAdapter β€” no scene tree required

Requirements

  • Godot 4.5+ with .NET support
  • .NET 8.0 SDK (or later)

GDScript projects can use this addon β€” Godot's cross-language scripting handles the interop automatically, but the .NET editor build is required.

Installation

  1. Copy addons/openfairway/ into your project's addons/ directory.
  2. Ensure your project has a C# solution. If you don't have a .csproj/.sln yet, generate them via Project > Tools > C# > Create C# Solution in the Godot editor. Alternatively, create any temporary C# script (Node > Attach Script > Language: C#) and Godot will generate both files automatically.
  3. Build your project: Build > Build Project in the editor (Alt+B), or dotnet build YourProject.csproj from the command line.
  4. Enable the plugin: Project > Project Settings > Plugins > OpenFairway Physics.

Quick Start

C#

var bp = new BallPhysics();
var aero = new Aerodynamics();

var p = new PhysicsParams(
    airDensity: aero.GetAirDensity(0f, 75f, PhysicsEnums.Units.Imperial),
    airViscosity: aero.GetDynamicViscosity(75f, PhysicsEnums.Units.Imperial),
    dragScale: 1f, liftScale: 1f,
    kineticFriction: 0.30f, rollingFriction: 0.030f,
    grassViscosity: 0.001f, criticalAngle: 0.25f,
    floorNormal: Vector3.Up);

Vector3 force = bp.CalculateForces(velocity, omega, onGround, p);
Vector3 torque = bp.CalculateTorques(velocity, omega, onGround, p);

GDScript

var physics = BallPhysics.new()
var aero = Aerodynamics.new()

var params = PhysicsParams.new()
params.air_density = aero.get_air_density(0.0, 75.0, PhysicsEnums.Units.Imperial)
params.air_viscosity = aero.get_dynamic_viscosity(75.0, PhysicsEnums.Units.Imperial)
params.drag_scale = 1.0
params.lift_scale = 1.0
params.floor_normal = Vector3.UP

var force = physics.calculate_forces(velocity, omega, false, params)

Headless Simulation

Run a full shot with no scene tree:

var adapter = new PhysicsAdapter();
var result = adapter.SimulateShotFromJson(new Godot.Collections.Dictionary
{
    ["BallData"] = new Godot.Collections.Dictionary
    {
        ["Speed"] = 150.0,       // mph
        ["VLA"] = 12.5,          // degrees
        ["HLA"] = 0.0,           // degrees
        ["TotalSpin"] = 2800,    // RPM
        ["SpinAxis"] = 0.0       // degrees
    }
});
// result["carry_yd"], result["total_yd"]

Distance Benchmarks

Run all 9 test shots headlessly and produce a carry/total/rollout distance table:

godot --headless --script run_benchmarks.gd

This is the standard way to validate physics changes. See tests/PhysicsTests/README.md for baseline distances and the full testing workflow.

Addon Classes

Class Base Description
BallPhysics RefCounted Force, torque, and bounce calculations
PhysicsParams Resource Exported physics parameters
BounceResult RefCounted Bounce calculation result
Aerodynamics RefCounted Drag/lift coefficients, air density, viscosity
Surface RefCounted Surface parameter presets
ShotSetup RefCounted Spin parsing and launch vector utilities
PhysicsAdapter RefCounted Headless shot simulator

All C# classes use [GlobalClass] for GDScript visibility. Enums are provided via physics_enums.gd (GDScript mirror of the C# PhysicsEnums definitions).

Addon Structure

addons/openfairway/
β”œβ”€β”€ plugin.cfg            Godot plugin metadata
β”œβ”€β”€ plugin.gd             Plugin entry point
β”œβ”€β”€ physics_enums.gd      GDScript enum mirror (BallState, Units, SurfaceType)
β”œβ”€β”€ LICENSE               MIT license
β”œβ”€β”€ README.md             Full GDScript API reference and examples
└── physics/
    β”œβ”€β”€ BallPhysics.cs    Force/torque/bounce calculations
    β”œβ”€β”€ PhysicsParams.cs  Physics parameters (Resource, exported)
    β”œβ”€β”€ BounceResult.cs   Bounce result data
    β”œβ”€β”€ Aerodynamics.cs   Cd/Cl coefficients, air properties
    β”œβ”€β”€ Surface.cs        Surface parameter presets
    β”œβ”€β”€ ShotSetup.cs      Spin parsing & launch vector utilities
    β”œβ”€β”€ PhysicsAdapter.cs Headless shot simulator
    β”œβ”€β”€ PhysicsEnums.cs   C# enum definitions (static class)
    └── README.md         Physics formulas and tuning guide

Documentation

  • Addon README β€” full GDScript API reference, installation details, complete physics loop and headless simulation examples
  • Physics README β€” force/torque formulas, bounce model, aerodynamic coefficients, unit conversions, tuning guide, and references

Units Convention

The physics engine always uses SI internally (meters, m/s, rad/s). Launch monitor input uses Imperial (mph, degrees, RPM). Display conversion is the consumer's responsibility. See ShotSetup.BuildLaunchVectors() for the standard conversion path.

License

MIT β€” see LICENSE.

An open source golf physics simulator library.
- v1.0.2 - Major Bug fixes in physics. Y clamp down fix. Lets ball react more natural using Jolt physics.
- v1.0.1
- Supports logging control (e.g. error, info, verbose)
- Asset only downloads addon, nothing else.
- v1.0.0
- First Publish (working physics library with docs)

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
OpenFairWay Golf Physics Simulator Library icon image
jesseincode
OpenFairWay Golf Physics Simulator Library

An open source golf physics simulator library.- v1.0.2 - Major Bug fixes in physics. Y clamp down fix. Lets ball react more natural using Jolt physics. - v1.0.1 - Supports logging control (e.g. error, info, verbose)- Asset only downloads addon, nothing else. - v1.0.0 - First Publish (working physics library with docs)

Supported Engine Version
4.5
Version String
1.0.2
License Version
MIT
Support Level
community
Modified Date
5 days ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers