Minimap is displayed as slightly inaccurate, especially when further from the origin point (0, 0, 0)

Hi, I’ve been struggling with an issue regarding minimaps. The effect I want to achieve is

  • Entire minimap moves, but the ‘player position’ is a stand-still dot in the center
  • Compensate for different map sizes, as well as the fact that maps are procedurally generated

However, the minimap’s positioning gets inaccurate, and often at seemingly random.
Here’s my code:

local function renderStep()
	local size = _G.MapCanvas * cellSize
	local myPos = myRoot.Position
	
	--[[
	problem:
	
	the scale gets a bit more distorted the more you're away from teh center?
	the very left edge: -0.2
	the very right edge: 1.13...????
	the very top edge: 0.1
	the very bottom edge: 0.85
	
	WHAT
	--]]
	
	minimap.Grid.Grid.Grid.Size = UDim2.new(0, size.X, 0, size.Y)
	
	-- + size.X / 2
	-- + size.Y / 2
	local ratioX = (myPos.Z + size.X / 2) / size.X
	local ratioY = (myPos.X + size.Y / 2) / size.Y
	
	print(ratioX, ratioY)
	
	--(cellSize / 2) * 1
	minimap.Grid.Grid.Grid.Position = UDim2.new(1 - ratioY, 0, 1 - ratioX, 0)
end

Here’s the video of me demonstrating the inaccuracy (pay attention to the minimap on the top right)

External Media

Any help would be appreciated

1 Like