Implementing Custom Rules (IScatterRule)

You can extend EnviroScatter Pro AI by implementing the IScatterRule interface to create custom spatial constraints.

using UnityEngine;
using ByteLura.EnviroScatter.Editor.Rules;
using ByteLura.EnviroScatter.Editor.Sampling;

public class WaterProximityRule : IScatterRule
{
    public float minWaterDistance = 3.0f;
    public LayerMask waterLayerMask;

    public bool Evaluate(ScatterCandidate candidate, ScatterProfile profile)
    {
        // Reject candidate if too close to water colliders
        Collider[] hits = Physics.OverlapSphere(candidate.position, minWaterDistance, waterLayerMask);
        return hits.Length == 0;
    }
}