Move texture based on actor world location
I’m trying to make a laptop with a screen that displays the minimap around it in the world. To do that, I already have a minimap system up and running and I created a dynamic material to get the minimap texture for each map. The texture is being displayed correctly in-game.
But now I want to zoom in on the actor’s position on the screen. Here’s what I did:
-Each map has two empty actors used as boundaries markers to generate the minimaps.
-I used these actors to get their world coords
-I then substracted the X and Y coords of each actor to get the map size
-Then I divided by two these X and Y sizes to get the origin point of each map (not at 0;0 on each map)
-I substracted the X and Y coords of the laptop with the X and Y coords of the map’s origin to get the laptop relative position
-I divided the X and Y relative coords by the X and Y sizes of the map to get a value between 0 and 1
The actual blueprint of the gobbledygook I just wrote
I now need to actually offset the texture to get it centered on the laptop’s position
For that, I added tiling and X;Y offset parameters to my material like this:
The blueprint that adds tiling and offset to the texture
The “Add” node on the far right is then connected to the UV input node of every texture I have in this material.