Class WithinRangeCondition
Passes when the evaluated character is within a distance of the initiator.
[Serializable]
public class WithinRangeCondition : BaseCondition, ICondition
- Inheritance
-
WithinRangeCondition
- Implements
- Inherited Members
Remarks
Position-sensitive, and that has consequences. This is the first shipped condition
whose answer depends on where characters ARE rather than on what state they hold, so it is
the first that can disagree with the query that produced its candidate. Every selector that
queries space evaluates its conditions inside the same lag-compensation scope as the query
(see TargetSelector.GatherRewound), so used there this measures the same world the
candidate came from.
Used anywhere else — attached to a Trigger's top-level conditions, or to a condition's own TargetSelector — it measures live server positions instead. That is not wrong, but it is a different question, and at 300 ms of latency the two answers differ by a couple of metres. Prefer a generous radius over a tight one for exactly that reason: this is a gate, not a hit test. A hit test belongs in a selector.
Distance is measured between transform origins and compared squared, so no square root runs per candidate. IgnoreVerticalDistance makes it a cylinder rather than a sphere, which is usually what an authored "within 10 metres" means on terrain with any relief.
Fields
IgnoreVerticalDistance
When true, distance is measured on the horizontal plane only.
[Tooltip("Measure horizontal distance only, ignoring height difference.")]
public bool IgnoreVerticalDistance
Field Value
Remarks
A sphere centred on a caster reaches less far along the ground as the height difference grows, so a target on a ledge one metre up is out of a ten metre sphere at 9.95 metres horizontally. Authors almost always mean the cylinder.
MaximumRange
Maximum distance, in metres, between the initiator and the evaluated character.
[Tooltip("Maximum distance in metres. Generous values are preferred; this is a gate, not a hit test.")]
[Min(0)]
public float MaximumRange
Field Value
MinimumRange
Minimum distance, in metres. Zero means no minimum.
[Tooltip("Minimum distance in metres. 0 for no minimum. Must be below Maximum Range to ever pass.")]
[Min(0)]
public float MinimumRange
Field Value
Remarks
For abilities with a dead zone — a ranged attack that cannot be used point blank. A minimum above MaximumRange can never pass, which is a misconfiguration this does not silently repair: swapping them would make an authored mistake behave plausibly and hide itself.
Methods
Evaluate(ICharacter, EventData)
Evaluates the condition's raw pass/fail logic. Must be implemented by derived classes. Derived classes should NOT apply Invert themselves — the framework calls Check(ICharacter, EventData), which wraps this method and applies Invert uniformly.
public override bool Evaluate(ICharacter initiator, EventData eventData)
Parameters
initiatorICharacterThe character initiating the check.
eventDataEventDataOptional event data for the condition.
Returns
- bool
True if the underlying check passes; otherwise, false.