VITALII YURCHENKO - Fuzzy Logic

Stop building gameplay decisions from endless thresholds.

Distance. Health. Heat. Visibility. Risk. Accuracy. Confidence. Speed.

It starts with a few Branch nodes β€” and soon the AI jumps between states, tuning one condition breaks another, and nobody remembers why 0.67 is the magic number.

πŸš€ Fuzzy Logic for Unreal Engine is built to solve exactly that.

Instead of β€œtrue or false?”, describe gameplay with natural concepts:

Target is Near β€’ Health is Low β€’ Weapon is Hot β€’ Threat is High β€’ Aim is Accurate

Then combine them in readable rules:

IF Distance IS Near AND Health IS High THEN Aggression IS Strong

IF AimError IS Low AND WeaponHeat IS Safe THEN FireConfidence IS High

IF Threat IS High AND Cover IS Poor THEN RetreatUrgency IS Strong

The result is a smooth number you can use immediately: Aggression = 0.73, AimSpeed = 0.48, FireConfidence = 0.81.

No sudden behaviour changes at arbitrary borders. No giant web of special cases.

Why Fuzzy Logic?

Traditional conditions have hard edges. An enemy using Distance < 500 may constantly switch between attack and idle. Add health, visibility, danger β€” and the decision tree becomes fragile.

Fuzzy Logic lets one value partially belong to several concepts. A target can be 70 % Near and 30 % Medium. Rules blend these degrees into stable decisions.

Use results to drive:

βœ… AI aggression, caution, retreat, target priority

βœ… Turret aim speed & fire confidence

βœ… Vehicle steering, braking, traction, throttle

βœ… Animation blending

βœ… Dynamic difficulty & encounter intensity

βœ… Risk, quality, desirability scoring

Works alongside Behaviour Trees, State Trees and gameplay code by answering β€œhow much?”

Author Behaviour as Data

Create a reusable Fuzzy System Data Asset:

  • Numeric inputs & outputs with ranges

  • Named fuzzy sets

  • Readable IF / THEN rules

  • Inference settings

One asset can be shared by many actors; every component keeps its own live values.

Need a quick experiment? Author the system inline on the component, then move it to a Data Asset later.

Designers tune behaviour without touching Blueprints or recompiling C++.

Purpose-Built Native Editor

Double-click a Fuzzy System asset β†’ dedicated Unreal Editor toolkit.

Edit inputs, outputs, rules and membership functions with standard Unreal controls. Curve thumbnails make every set readable.

Move live input sliders and instantly see membership degrees, crisp outputs, aggregated curves, defuzzified markers and rule firing strengths.

Compile Log reports invalid ranges, duplicate names, unknown variables, malformed rules and missing coverage.

Readable Rule Language

IF / THEN β€’ AND β€’ OR β€’ NOT β€’ WITH rule weights

Examples:

IF Distance IS Near THEN Braking IS Strong

IF Visibility IS Poor OR TargetSpeed IS High THEN AimSpeed IS Careful

IF Health IS NOT High THEN RetreatUrgency IS Medium WITH 0.8

Rules are compiled once; the engine never reparses text in the hot path.

Nine Membership Shapes

Triangle, Trapezoid, Gaussian, Bell, Sigmoid, Ramp, J-Shape, Singleton, Constant (all invertible).

Add custom shapes in C++ by deriving from FFuzzyMembershipFunction β€” editor and tools discover them via reflection.

Complete Mamdani Pipeline

Fuzzification β†’ rule evaluation β†’ implication β†’ aggregation β†’ defuzzification.

Choose operators for AND/OR, Clip or Scale implication, three aggregation modes and six defuzzification methods (Centroid, Bisector, Mean/Smallest/Largest of Maxima, Weighted Average).

One System, Multiple Decisions

A drone turns Distance, ReactorHeat, Integrity β†’ Aggression, OrbitSpeed, Altitude.

A turret turns TargetDistance, ClosingRate, AimError, WeaponHeat β†’ ThreatPriority, TraverseSpeed, FireConfidence.

A vehicle turns Speed, Grip, TurnAngle, ObstacleDistance β†’ Throttle, Steering, Braking.

Simple Blueprint Workflow

Add the component β†’ Set Input(s) β†’ Evaluate β†’ Apply Result.

Or update a Map of values. Evaluate nodes are intentionally impure so calculation runs exactly where the execution wire requests it.

Full result contains crisp outputs, memberships, rule strengths and diagnostics β€” decisions stay explainable.

JSON Presets

Load / Save versioned JSON for source control, external tools or moving systems between projects.

Load validates the entire file before touching the asset (bad file leaves it unchanged + Undo support).

Validation You Can Trust

UFuzzySystemAsset integrates with Unreal content validation. Diagnostics cover invalid ranges, duplicate names, unknown variables, bad rule syntax, missing rules and β€œno rule fired” cases.

UMG Visualisation

Draw membership sets, aggregated surfaces, crisp markers and rule strengths directly in a User Widget Paint event. Create debug HUDs and player-facing panels with live fuzzy-system data.

Built for Runtime

Rules compiled once, component caches its engine, shared Data Assets avoid duplication. For large crowds, UFuzzyLogicSubsystem compiles each asset once and shares the compiled engine across many agents, avoiding per-agent system copies and repeated compilation.

Tune cost via evaluation frequency, rule/output count, Sample Count and defuzzification method. Core runtime has zero Slate/UMG dependency.

βœ… Complete Mamdani engine

βœ… Reusable Data Assets + Actor Component

βœ… Blueprint + full C++ API

βœ… Nine extensible membership shapes

βœ… Weighted IF/THEN rules, multi-in/multi-out

βœ… Six defuzzification methods

βœ… Dedicated native editor with live preview

βœ… Versioned JSON import/export

βœ… Content validation & diagnostics

βœ… Optional UMG visualisation

βœ… 39 automated tests

βœ… Two demo scenes (Fuzzy Drone Arena & Fuzzy Turret Defense)

Create a Data Asset. Define concepts your team understands. Write the rules. Feed the inputs. Use the result.

Build gameplay behaviour β€” not another maze of thresholds.

Documentation: https://logdok.github.io/ue-plugins-docs/fuzzy-logic/Full/en/

YouTube chanel: https://www.youtube.com/playlist?list=PLZsyzWZW7t2Q

Support: https://discord.gg/F2WxM4zVzs