Location based, cylinder shaped opacity mask that always faces the camera and only masks faces that are facing away from the player character.

I have three problems I need to solve. I am trying to make a opacity mask that is in the shape of a cylinder with the other end pointy and the other flat. Both of the ends are pointy right now. The cylinder should rotate to always face the camera and apply the opacity mask to faces that are facing away from the character. It should always reveal the player if he goes behind any object with the material attached to it, no matter how far away he is or how many objects is in between the player and the camera. A simple sphere doesn’t do the job since it can’t mask all the objects that are in between the player and the camera: a long cylinder would do it.

The opacity mask is in the shape of this right now, always positioned around the player, but doesn’t rotate to face the camera.

Round shape of the cylinder.

This cube face shouldn’t be masked, since it is facing the player.

This is how I create the opacity mask shape from a world position.

This is how I get the player position and translate that to either be closer or further away from the player.

BONUS: How would I make the opacity masked materials still cast a full shadow, even if parts of the textures are inside the opacity mask?

This is an old question but here’s some answers:
Bonus: to get the shadow, use the node “ShadowPassSwitch” at the end of the whole operation, right before connecting it to the opacity mask. Set shadow to 1 and you will keep the shadow.

I tried it out and it successfully makes a cylinder that is location based but my trouble is the rotation. It always faces the Z axis. I haven’t figured out the rotation though.

I tried a RotateAboutAxis method but it failed…