How to create a minimap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By droc101

How would I map the 3d position of the player to a 128x128 map image? I have a variable representing the node with the farthest distance from the origin.

Can you post some example code? If you have a 3d position and want to represent 2 of the dimensions on a 2d area, you just need to use those 2 positions and scale down the distance? Or am I misunderstanding?

Becbunzen | 2020-06-02 18:15

It’s more of the math to determine the scale

droc101 | 2020-06-03 01:03

:bust_in_silhouette: Reply From: Becbunzen

Scaling down should be very simple math? Can you post the code you want help with?

It’s more of finding the scale, not scaling down. I have a float representing the farthest node’s distance from the 3d origin, plus some. I want to know how to make a scale from that

droc101 | 2020-06-03 14:39

I do not understand. Finding the scale, to me, sounds like you do that by deciding how large the minimap should be. Then you scale things down to match the minimap. What am I not understanding?

Becbunzen | 2020-06-03 14:56

How to convert the 3d scene size to a divisor for the player position

droc101 | 2020-06-03 19:17

What do you mean by divisor? If you have a 3d map and want to show a 2d position, ignore the 2d vector. Then scale down from the world map size to the minimap size.

Becbunzen | 2020-06-03 19:30

My idea was something like this:
get max world size (done)
get the scale of the world vs minimap (let’s say .5) <== This is the step I can’t figure out,
player world x and z * .5 = minimap position

droc101 | 2020-06-03 19:35

What is the size of your world? What is the size of the minimap?

World is size 1000x1000. Minimap is size 2x2. Ignore z-axis. Player is in position 230x740. Calculate x-position on minimap as 230*2/1000, y-position as 740*2/1000. 

Becbunzen | 2020-06-03 21:49

I plugged in that math, and sadly the player indicator still goes off the map.
Mini map is 185x185
World size is a variable determined by the distance to the farthest node from the origin plus 100

droc101 | 2020-06-03 23:02

Never mind I solved it with a level data node in each scene.

droc101 | 2020-06-03 23:16