How could I develop something that’s able to track and record the route the player takes around a map.
First bit is pretty straightforward (logging players location coordinates), but is there a way to get the engine to draw the players path on an image that goes to the logfile etc?
What I mean is can ue4 output something that looks like a minimap of a room with the players route drawn on it?
I’m not building a logfile out of images as I don’t know how, but I’m asking is this possible? Can we extract the x,y coordinates from the game and plot a drawn path from them?
You can make a classic minimap, there are many tutorials on YT. In your case in addition to drawing the player’s icon at the current location, you’d also loop through the array of the logged locations you mentioned and draw them as well.
UMG user widget can override *onPaint *which gives you context to *DrawBox *which, in turn, uses a Brush. You can set it up with an image in the Content Browser; it’s pretty efficient as far as I know. OnPaint can also draw lines but no splines, which saddens me greatly taking into account that blueprints use splines for wires…
edit: never done anything like that, if someone else claims there’s a better way, they’re probably right. That’s just what I’d try. I just tested drawing 10000 brushes and it works, it’s kind of heavy on the frame rate, though. Depending on how complex this system is going to be, you’ll most likely not need more than a 1000.
A bit curious about how much faster the HUD class is at this, it’s supposed to be faster.
I still think that my original suggestions of drawing to material is better here. I’d look into that first.
Go with a render target. After scrubbing through the tutorial I linked, it seems to cover it all (and more). Instead of drawing on a 3d object, like the author does, assign the Render Target to a widget instead - use a border for simplicity sake. You will, obviously, not use a line trace for drawing but use your accumulated positional data to draw the whole thing once you’re ready.
You’ll need:
render target
a material for it
another material to draw with (draw dots, the more samples in your data, the better)
the data for the drawing
a widget to display the result on
Instead of keeping it in an actor, keep it all in the widget, loop through the positions you get from the character and Draw dots. Materials need 0-1 coords, you’ve got world coords - you can translate them with MapRange node, for example. [HR][/HR]Vid below, that’s what you’re after, right? You may need to flip some XYs to make things work right
I kept filling in a vector array with player positions on Tick. This gives a ton of data.
Loop through the array and draw all the data at once. Do mind that if you attempt to draw 10000 dots at once, you’ll get a hitch. This is probably irrelevant if you just want to display it on a static screen. On the other hand, you can draw it in real time - just don’t show it to the player until you’re ready…