Minimap not accurate

I need guidance with making my map accurate. Sometimes it is accurate and sometimes it is not.

local function UpPosition()
	local x = hrp.Position.x/MapDimensons.X + .263
	local z = hrp.Position.Z/MapDimensons.Z  + .590 
	PlayerIcon.Position =    UDim2.new(x, 0, z, 0)
end

That is used to update the dot

local MapDimensons = Vector3.new(8694.93, 206.887, 11472.275)

I got the map Dimension by placing 2 parts, one on the top left corner of the map, and one on the bottom right corner. I used

size = Vector3.new(
  math.abs(leftPart.x - rightPart.x),
  math.abs(leftPart.y - rightPart.y),
  math.abs(leftPart.z - rightPart.z)
)

This equation to get the size of a square covering the map which is used for the Dimension

The icon dot is not accurate and I am unsure where to go from here.

The X and Z distance is being calculated from WorldPosition (0, 0, 0), so your PlayerIcon is getting more and more inaccurate the further away you are from that point. So before your calculation, you’ll need to get the WorldPosition of the center of your map by doing

local MapCenter = (TopLeft.Position + BottomRight.Position) / 2

then for the X and Y scale for the PlayerIcon

local XPercent = .5 + ((hrp.Position.X - MapCenter.X) / MapSize.X)
local YPercent = .5 + ((hrp.Position.Z - MapCenter.Z) / MapSize.Y)
PlayerIcon.Position = UDim2.new(XPercent, 0, YPercent, 0)

When you first make these changes, the PlayerIcon could possibly be moving the opposite direction because it depends on how your map has been made on the world axis. Just add a negative after the .5 in the equation to reverse either the XPercent, YPercent, or both. You may also need to reverse the XPercent and YPercent in the PlayerIcon UDim2.

1 Like

Noticed the MapSize.Y should’ve been MapSize.Z, thank you so much for helping me!

1 Like

Oh yeah, sorry. My MapSize variable was a Vector2 instead of the Vector3 you have. No problem!

I am noticing it is still off when moving away from the center, I made a smaller map and did this to make it more simpler, here is a test place where you can test and see what I mean

What should I do from here?

The games private but here’s the mock setup I did while helping you. You should be able to edit it and look at the script.
https://www.roblox.com/games/11905693010/Minimap

1 Like

Thank you again, I am not sure where I went wrong but this will solve it, I really appreciate your time.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.