Announcement

Collapse
No announcement yet.

displaying a map and player position (converting between widget coords and screen position in BP)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    displaying a map and player position (converting between widget coords and screen position in BP)

    Hi all, beginner here, keep things easy.

    I am trying to display a map of my world and mark player position on it. When the player presses M program creates a widget which displays a bitmap with a map, that was an easy part. Problems start when I want to mark the player position (from GetActorLocation), for now with a simple DrawBox call in the overrided OnDraw function. That kind of works - I can DrawBox, but I have problems calculating correct coordinates to pass to the DrawBox. Seems like DrawBox works in a screen space, and I want to draw the mark relative to the bitmap position, so I need some converting/rescaling. Math would be rather simple, given some basic information. I can access some of the parameters required (like bitmap size, position) by calling MyMapBitmap->Slot as canvas slot->GetXXX functions, but that's hardly helpfull without screen size. From my googling seems like this can be checked only in HUD BP, not in a widget BP. At the same time I don't see how to draw over the bitmap in the HUD BP, as it doesn't have overridable OnDraw function.

    Does it mean I have to do some tricks to get both kind of data in one place? Or am I just going in a completely wrong direction?

    #2
    Seems like I missed the fact the GetPlayerContoller->GetVewportSize should give me the info I need, still, I am not convinced I am on the right track with my approach.

    Edit: no, it leads nowhere, even knowing size I still have no idea about the scaling of the map, as it depends on the screen size and the numbers returned by for the bitmap by GetSize are those enetered when designing widget, they have nothing to do with the display size
    Last edited by BoBorek; 05-09-2019, 10:14 AM.

    Comment

    Working...
    X