Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
August 22, 2023 09:23
January 9, 2022 23:18
August 22, 2023 09:23
August 22, 2023 09:23
January 21, 2021 11:24
August 18, 2023 12:23

Raycasting for Bevy

CI Bevy tracking

raycast demo

A Bevy plugin for 3D ray casting against meshes. Used to build bevy_mod_picking. Contributions welcome!


This plugin makes it simple to create ray casting sources, such as a transform (first person, third person shooter), or screenspace coordinates (mouse picking).

  • Only meshes that you mark with a component will be checked for intersections.
  • You can define which ray casting source(s) should interact with which mesh(es) by marking grouped sources and targets with the same type.
  • This plugin also provides some functionality to compute the intersection of rays with primitive shapes.
  • Acceleration is provided using Bevy's AABBs and visibility culling.
  • An immediate mode API is provided to allow raycasts on demand, as well as raycasting using components updated once per frame.


For a more full featured and performant option, consider using bevy_rapier. Note that rapier is a full physics engine that can also do raycasting; by contrast, this crate prioritizes simplicity and ergonomics.

Bevy Version Support

I intend to track the main branch of Bevy. PRs supporting this are welcome!

bevy bevy_mod_raycast
0.11 0.9, 0.10, 0.11, 0.12
0.10 0.8
0.9 0.7
0.8 0.6
0.7 0.4, 0.5
0.6 0.3
0.5 0.2
0.4 0.1


Mouse picking using a ray cast built using screen space coordinates:

cargo run --example mouse_picking

Mouse picking using a ray cast built using screen space coordinates, for 2D meshes:

cargo run --example mouse_picking_2d

Ray casting from a camera using ray casts from the camera entity's GlobalTransform:

cargo run --example minimal

Manually compute raycast against primitive shape, and check for line-of-sight visibility

cargo run --example ray_intersection_over_mesh

Optimization Mouse picking over many meshes using AABBs:

cargo run --example bounding_volume

Optimization Mouse picking over complicated mesh using simplified mesh for the raycasting:

cargo run --example simplified_mesh