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
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.