Skip to main content

check_line_of_sight

Function check_line_of_sight 

Source
pub fn check_line_of_sight(
    name: &str,
    agent_pos_key: &str,
    target_pos_key: &str,
    obstacles_key: &str,
    obstacle_radius: f32,
    max_range: f32,
) -> BehaviorNode
Expand description

Condition: can agent see target?

A simplified LOS check: reads the agent position and target position from the blackboard, then tests a list of obstacle positions stored under "{obstacles_key}" (a BlackboardValue::List of Vec3 entries).

For each obstacle sphere (radius obstacle_radius), the check performs a ray-sphere intersection. If any obstacle blocks the ray, returns Failure.

For games with a custom LOS system, replace this function with one that calls into your spatial query API — the signature is identical.