Hello! I have created I globe which moves based on the players mouse. Everything works fine, however I’m not sure I’d go about rotating it base on where the camera is facing. Here is a video of it:
https://gyazo.com/a82110a26bbd1769047730abc2f77a06
As seen in the video, it doesn’t rotate based off the camera.
An example of rotating based off the camera
The camera is facing from a top view. The mouse moving on the x axis would correspond to rotation on the z axis, and the mouse moving on the y axis would correspond to rotation on the x axis.
Currently the mouse moving on the x axis corresponds to rotation on the global y axis and the mouse moving on the y axis corresponds to rotation on the global x axis. I imagine my goal could be achieved by rotating the globe based on the local axes of the camera, but I’m not sure how I’d do this. I also don’t know how to select which axes to correspond the mouse movement and globe movement to.
My rotation script (incase it is useful):
local mousePos = UserInputSerivce:GetMouseLocation()
task.spawn(function()
while mouseDown == true do
local currentMousePos = UserInputSerivce:GetMouseLocation()
local dx, dy = (mousePos.X - currentMousePos.X) * sensitivity, (mousePos.Y - currentMousePos.Y) * sensitivity
primaryPart.CFrame = primaryPart.CFrame * CFrame.Angles( dy, -dx, 0 ) * (workspace.CurrentCamera.CFrame - workspace.CurrentCamera.CFrame.Position) -- rotates base on world space
mousePos = currentMousePos
wait()
end
end)
Any help is appreciated, thanks!