-
Notifications
You must be signed in to change notification settings - Fork 49
Using the obstacle radar
Idan Arye edited this page Apr 22, 2025
·
2 revisions
Insert the radar component using:
cmd.insert(TnuaObstacleRadar::new(1.0, 3.0));The radar is a cylinder, with the first parameter of new being the radius and the second parameter the height.
The radar will detect all colliders in range, but it'll only store the entities themselves, so you'd usually want to combine it with the spatial extension from the physics backend crate into a TnuaRadarLens:
fn user_control_system(
mut query: Query<(&mut TnuaController, &TnuaObstacleRadar)>,
spatial_ext: TnuaSpatialExtAvian3d, // this depends on the physics backend you use
) {
for (controller, obstacle_radar) in query.iter_mut() {
let radar_lens = TnuaRadarLens::new(obstacle_radar, &spatial_ext);
// ...
}
}Then you can iterate the blips:
for blip in radar_lens.iter_blips() {
// ...
}And decide what to do with each blip.
Note that:
- The
blipis of typeTnuaRadarBlipLens, which contain useful helper methods for inspecting the geometry. - All colliders create blips when in range - it's up to the user system to filter out the ones it needs (e.g. only support wall jumping from walls that have a certain marker component on them)