Need help to mask heat distortion effect - SOLVED -

I’m trying to create a scene where a moving vessel approaches and passes the camera. The camera pans with the motion, so you see the back end of the vessel moving away. I want to use the heat distortion effect shown in the example I found here to be emitted out of the engines. The problem is, in the demonstration, the mask is generated by a separate object, which ends up masking the distortion, even if it is behind the effect. I need to be able to mask the distortion when the ship is naturally in between the camera and the effect, and have the distortion naturally reveal itself as the ship passes by. Does anyone know how to do this?

Thanks.

Object Id pass for the ship object?

I looked up videos for Object ID pass and see problems with this approach. First, all the videos were single frame renders. Would it work the same on a multi-frame render? Second, It masks the whole object. This would be a problem because I need a complex motion of the camera where it pans with the moving ship. The heat distortion I need to incorporate would need to be masked by the ship while it is behind the ship, but would need to be unmasked as the ship passes, and the heat distortion is between the ship and the camera. Also, the distortion would be generated within the ship’s reactor bell. That means that as the ship passes by the camera, the furthest part of the bell would be behind the distortion while the closest part would be in front of it. Anyone know how to accomplish this?

OK. Just realized I misunderstood the original video. It does exactly what I need as long as the particle emitter is a child of the ship object. Created a Blender project to test it, and it worked fine.