CGI: How to make object disappear as it moves behind a person?

I’m animating a 3D ball bouncing in front of then behind a person. (The footage is completely still and the person is barely moving.)

Here’s what comes to mind…
• I could render the 3D animation of just the ball onto alpha, and drag that rendered clip into the VSE as an ‘alpha over’ over the real footage, and add a transparent mask around the person’s outline and only activate it to subtract from the 3D clip when the ball is supposed to be going behind the person.
• Or…I could create an object in roughly the shape of the person, then add an ‘alpha’ texture to that object—in such a way that when the ball goes behind the object it disappears. After that, it would be ideal if there’d be some way to specify, “Hey Blender, just render the video background over this person-object’s alpha texture.” If there’s not, I’d have to again export that and the add it back into the VSE as alpha over again; the only advantage to this being I wouldn’t have to create a mask since the ball would already be disappearing.

Is there easier or other way, or what do my options look like here?

The most common way to do this is with Z-Depth, which is an indication of how far away the object is from the camera. You can then use this to select the object that is closest.

I don’t follow. I looked up what Z-Depth is, but how does that relate to my issue of how to hide the ball when it should pass behind the video clip’s subject?

If the person in the shot is “real,” you’ll need to create a proxy mask to represent where he is standing, but basically you calculate the Z-depth of both objects and use this to mask-out the object that is farther away when one passes behind the other.

Oh, got it. That would make sense; what I ended up doing though was just making a mask of the body and automating it to hide/unhide, which wasn’t tedious given the brevity of the scene