RayCast2D
Cast a ray and detect the first physics body it hits for line-of-sight and targeting.
Physics/Query
No shortcutIntermediate5 min readQuick Reference
RayCast2D
Godot EngineKeyboard Shortcut
N/A
Where to Find
Scene dock — Create New Node > Node2D > Physics > RayCast2D
Best Used For
- ▸Detect line-of-sight between characters
- ▸Implement weapon targeting and hit detection
- ▸Check for ground, walls, and ledges
Intermediate⏱ 30–60 minutes to master
Key Settings
Add:Check:
RayCast2D casts a ray in a direction and detects the first physics body hit. Used for line-of-sight, targeting, and ground detection.
Where to Find It
Found under Node2D > Physics.
How to Use
- Add: Add as child of the casting character.
- Check: Use
is_colliding()andget_collider().
Pro Tips
- Use
force_raycast_update()for manual triggering. - Enable Debug Shape to see the ray in the editor.