extracted raycasting to physics_system to simplify code