Class HasLineOfSightCondition
Passes when nothing blocks the line from the initiator to the evaluated character.
[Serializable]
public class HasLineOfSightCondition : BaseCondition, ICondition
- Inheritance
-
HasLineOfSightCondition
- Implements
- Inherited Members
Remarks
Tests world geometry, never characters. Blockers should name terrain and structures. Including the character layer would make the answer depend on where every OTHER character stands, which is both the peer-position sensitivity this project works to avoid and a rule players cannot predict — a teammate walking through the line would cancel an ability mid-cast. Terrain does not move, so this needs no lag compensation to be correct, and it stays correct at any latency.
This mirrors the line-of-sight option on TargetedEntitySelector deliberately: the same
test, available as a condition so it can gate abilities that select their targets some other
way.
Fields
Blockers
Layers treated as sight-blocking.
[Tooltip("Layers that block sight. Should contain terrain and structures, never characters.")]
public LayerMask Blockers
Field Value
- LayerMask
Remarks
Empty means nothing blocks, so the condition passes. That is the safe default for an unconfigured condition: refusing every cast because a layer mask was left unset is a silent, total failure, while passing is merely the absence of a restriction the author has not finished expressing.
EyeHeight
Vertical offset applied to both ends of the test, so it does not clip the ground.
[Tooltip("Eye height for both ends of the line, so the test does not clip the ground.")]
[Min(0)]
public float EyeHeight
Field Value
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.