Dynamic material mask weird movement

Hello,

I have an issue with a dynamic material I’m working on, and I’m losing my mind on it, so I hope someone can help me.

The intention is this: my player pawn can sometimes overlap with big meshes. When it happens, I change the material on the big mesh to have a spherical mask show at the player’s screen position. That mask follows the player, to make sure it stays visible.
Meanwhile, the camera can either be locked on the player or scroll by placing the mouse on the edges of the screen.

I have something that works to some extent. The camera is fine. I have the mask, and it kind of follows the player, but it seems there is an issue with the X axis.

Basically, if I scroll up or down, the mask stays on the player, but if I scroll left or right, it doesn’t. It’s not like it follows the camera instead, more like there is an increasing offset applied to it. This is very weird to me because I don’t treat X and Y differently, so I don’t understand how I can get such different behaviors.

Same when the player starts going left or right, the mask gets offset.

If the camera is locked on the player, it works well.

This is the player (green), the big mesh and the mask
Capture

This is how I feed the parameters to the material (executed every frame). I had to set the viewport size manually because the ScreenResolution node would return strange data. I also tried with a ConvertWorldLocationToScreenPosition instead of the Project node, same result. The location it receives is the world location for the player pawn.

This is the part of the material where I find the position. It goes into the material’s Opacity pin.

If someone knows what happens I’d be very greateful. Sorry for the wall of text.

Bumping this in hope of an answer

Looking at your Blueprint graphs, the logic seems fine. You mention you can scroll up and down, as well as left and right - not sure how to imagine this, is it like scrolling on a website (lateral movement)? Maybe you can send us a GIF of the unexpected behavior, then we might be able to help better!

Thank you for your reply. I made a quick video of the issue. I hope you’re able to read it:

On the video you can see at the start that the player (in green) is inside the white mesh but there’s a mask on it to maintain visibility. Then I scroll in all direction and as I explained, the issue happens from left to right.