Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making minimap with overlapping bricks?

Asked by
KoreanBBQ 301 Moderation Voter
9 years ago

Hello I made a minimap but it's not perfect when I have overlapping bricks.

How my minimap works is it goes through workspace's children, creates a frame of proportional size and puts it on the GUI. rotation, positionning, everything is fine.

Now when I have overlapping bricks, since ZIndex is scaled on 10, I cant just make it proportional to Position.Y+.5*Size.Y

So I made it so after it's positionned everything, it loops through all the parts(part A), and for every single part, loop through all parts and checks with every possible part(part B) if there is a collision on the minimap.

If it does find a collision, it sets Part A's ZIndex to B's+1

But it's REALLY not working correctly.

Look at the Collision section of the code:

for _,image in pairs(imagedParts) do
                for ind,gui in pairs(imagedParts) do
                    local collision=false
                    if gui~=image and gui.Position.Y.Scale<image.Position.Y.Scale+image.Size.Y.Scale and
                        gui.Position.Y.Scale>image.Position.Y.Scale-(image.Size.Y.Scale/2) and
                        gui.Position.X.Scale<image.Position.X.Scale+image.Size.X.Scale and
                        gui.Position.X.Scale+gui.Size.X.Scale>image.Position.X.Scale then
                         --Downward edge collide

                         collision=true
                     end
                     if gui~=image and gui.Position.Y.Scale+gui.Size.Y.Scale>image.Position.Y.Scale and
                        gui.Position.Y.Scale+gui.Size.Y.Scale<image.Position.Y.Scale+(image.Size.Y.Scale/2) and
                        gui.Position.X.Scale<image.Position.X.Scale+image.Size.X.Scale and
                        gui.Position.X.Scale+gui.Size.X.Scale>image.Position.X.Scale then
                         -- Upward edge collide

                         collision=true
                     end
                     if gui~=image and gui.Position.X.Scale+gui.Size.X.Scale>image.Position.X.Scale and
                        gui.Position.X.Scale+gui.Size.X.Scale<image.Position.X.Scale-(image.Size.X.Scale/2) and
                        gui.Position.Y.Scale<image.Position.Y.Scale+image.Size.Y.Scale and
                        gui.Position.Y.Scale+gui.Size.Y.Scale>image.Position.Y.Scale then
                         -- Left edge collide

                         collision=true
                     end
                     if gui~=image and gui.Position.X.Scale<image.Position.X.Scale+image.Size.X.Scale and
                        gui.Position.X.Scale>image.Position.X.Scale+(image.Size.X.Scale/2) and
                        gui.Position.Y.Scale<image.Position.Y.Scale+image.Size.Y.Scale and
                        gui.Position.Y.Scale+gui.Size.Y.Scale>image.Position.Y.Scale then
                         -- Right edge collide

                         collision=true
                     end
                    if collision then --WHERE THE TROUBLE STARTS
                        local topY=original[image].Position.Y+0.5*original[image].Size.Y
                        local guiY=original[gui].Position.Y+0.5*original[gui].Size.Y
                        if guiY>topY then
                            image.ZIndex=gui.ZIndex-1
                        elseif guiY<topY then
                            image.ZIndex=gui.ZIndex+1
                        end
                    end
                end
            end

Sorry if code's long but you can pretty much start looking at it where i say the trouble starts.

this is really difficult thank you ill make my minimap free

0
Would it work to just not use index, and arrange the GUIs in a table and putting them in in order of height or wtv? KoreanBBQ 301 — 9y

Answer this question