How would I replicate the camera rotation on a minimap?

Hello, currently I am trying to make a minimap. I am doing this with viewport frames, and I have a seperate camera that is right above the player at all times. I want the minimap cameras orientation to match the orientation with the players camera, however I am not sure how to do this. I tried using lookvector, but I was unsure how to actually make it match up. How would I do this?


Heres some more context if you need it, the minimap is in the top right, and when I rotate my camera around, I would like the minimap to also rotate around. What is being printed in the output is the players cameras lookvector

Firstly, you can obtain the camera rotation using:

local X,Y,Z = workspace.CurrentCamera.CFrame:ToOrientation()

X,Y,Z are in radians, so math.rad(y) is the left-right rotation angle of the camera.

Then, you will want to rotate the minimap.
To rotate it, i recommend you to look up about the image Rect properties, although I am not confident a RectRotation exists.

And tadah, you are 50% done
Maybe you wil want to use a circular minimap so it will be easier to rotate about.

I cant just rotate the actual CurrentCamera, Id have to rotate the actual map?

I think the rotation of the Camera would be the X or Y axis from the LookVector.

minimap.Orientation = camera.CFrame.LookVector * Vector3.new(0,1,0)

edit: or maybe this works!

minimapcamera.CFrame = camera.CFrame * CFrame.new(camera.CFrame.Position,camera.CFrame.LookVector * Vector3.new(0,1,0))

There might be an issue with this :joy:

DANG so close! Seemingly got it orienting but not offsetting to your position and also the math I did must be way wrong too lol

Maybe this works?

minimapcamera.CFrame = CFrame.fromOrientation(-math.pi/2,select(2,camera.CFrame:ToOrientation()),0) + humanoidrootpart.Position + Vector3.new(0,50,0)

You can use the humanoidrootpart to position the camera then add a Vector3 to increase the height of the camera

1 Like

That works :smiley:
Thank you so much i was really confused on this