I'm working on a mini-map, but I'm having problems with making the arrow in the center rotate to match the camera's rotation.
( Like in any RPG mini-map. The arrow points towards the direction you're facing.)
I've tried using lookVector and :toEulerAnglesXYZ(), but neither seem to work correctly.
The two codes I've tried are;
local x,y = workspace.CurrentCamera.CoordinateFrame:toEulerAnglesXYZ(); script.Parent.Frame.Dot.Arrow.Rotation = math.deg(x); and script.Parent.Frame.Dot.Arrow.Rotation = math.deg(workspace.CurrentCamera.CoordinateFrame.lookVector.X);
What you are looking for in the three shown in the above article is Heading, which, when looking from the top down as in a minimap, shows which direction on ROBLOX's xz plane the camera is facing.
local pip = script.Parent.Frame.Dot.Arrow local sx, sy, sz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = Workspace.CurrentCamera.CoordinateFrame:components() heading = math.atan2(m02, m22) pip.Rotation = math.deg(heading)
Now, this will error if the camera is looking directly downwards, or directly upwards, since the heading will not be determinable. However, ROBLOX by default doesn't allow for this.