I think that it is usually done by a c_trace.
If it hitted an other entity, the you pointer is set to that entity and you can do what ever you want with it. c_scan should work, too.

Just look it both up in the manual.