How do i make a procedural minimap

i have a game that’s procedurally generated and i have no idea how to make a minimap for that game in the top right corner of a players gui that displays a top down of the procedural world

the world is made out of terrain and meshes

the only thing i can think about is to make a bunch of frames in a grid and update them to the corresponding color each frame but that wouldn’t be flexible to each players resolution and not efficient either

1 Like

I’d make it the grid of frames that you color based off of raycasts down to the ground in a grid around the player’s character. You can adjust the resolution via things like UiAspectRatioConstraint instances inside of the frames, and/or dynamic resolution of the minimap.

So, something like this:

local mapResolution = 10
local areaSize = 100

local searchSize = areaSize/2

for z = -searchSize,searchSize,searchSize/mapResolution do
	for x = -searchSize,searchSize,searchSize/mapResolution do
		local raycastPos = character.HumanoidRootPart.Position+Vector3.new(x,100,z)
		local raycastDir = Vector3.new(0,-200,0)
		
		local raycastParams = RaycastParams.new() --blah blah
		raycastParams.FilterType = Enum.RaycastFilterType.Exclude
		raycastParams.FilterDescendantsInstances = {listOfAllCharacters, listOfAllNonMapThingies} --listOfAllNonMapThingies = npcs, dropped items, etc 
		-- or, you could do include for the whole map + terrain, instead
		
		local raycastResult = game.Workspace:Raycast(raycastPos,raycastDir,raycastParams)
		
		if raycastResult then
			if raycastResult.Instance == game.Workspace.Terrain then
				frame.BackgroundColor3 = game.Workspace.Terrain:GetMaterialColor(raycastResult.Material)
			elseif raycastResult.Instance:IsA("BasePart") then
				frame.BackgroundColor3 = raycastResult.Instance.Color3
			end
		else
			frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
		end
		
	end
end

This might be scuffed or straight up not work, but it should get you started. Ask if you need anything more!

1 Like

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