I changed the camera with this code and it moved it…? I took ratios, you can try percentages. multiply ratioX and ratioY by 100
Can you just make your viewport frame full screen make a copy of some map and see that it’s not working?
I dont understand what you want exactly which makes it harder, would you mind sending a place file for me to edit it something?
sorry for late reply, was sleeping
Is this what you want?
local Players = game:GetService('Players');
local RunService = game:GetService('RunService');
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable;
local Player = Players.LocalPlayer;
local MouseObj = Player:GetMouse();
local Sensitivity = 100;
local Displacement = Vector2.zero;
local CameraAngleX, CameraAngleY = 0, 0;
local function ClampAngle(Angle)
if (Angle > 360) then
Angle -= 360;
elseif (Angle < 0) then
Angle += 360;
end
return Angle;
end
MouseObj.Move:Connect(function()
local Middle = Camera.ViewportSize/2;
local MousePosition = Vector2.new(MouseObj.X , MouseObj.Y);
local MoveFactor = (MousePosition/Middle) - Vector2.one;
Displacement = MoveFactor;
end)
RunService.RenderStepped:Connect(function(deltaTime)
CameraAngleX = ClampAngle(CameraAngleX - (Displacement.X * Sensitivity * deltaTime));
CameraAngleY = math.clamp(CameraAngleY - (Displacement.Y * Sensitivity * deltaTime), -80, 80);
local RadAngleX, RadAngleY =
math.rad(CameraAngleX),
math.rad(CameraAngleY);
local CosY, SinY =
math.cos(RadAngleX),
math.sin(RadAngleX);
local CosX, SinX =
math.cos(RadAngleY),
math.sin(RadAngleY);
Camera.CFrame = CFrame.new(Camera.CFrame.Position) * CFrame.new(
0, 0, 0,
CosY, SinY*SinX, SinY*CosX,
0, CosX, -SinX,
-SinY, CosY*SinX, CosY*CosX
);
end)
Alright, saying to everyone. If you want to test if your methods work, make a Viewport frame with scaling x 1 and scaling y 1 and make it so every frame it will have the position of the mouse (with anchor points 0.5x 0.5y). Add to viewport baseplate and see if baseplate in viewport with your camera and your method is the same as baseplate in real world. I’m getting something like that, so that’s not working
I have no clue what you want, perhaps you mean offset the camera depending on the mouse position? Or just rotate the camera like a freecam?
“This small cubes inside “screens” is mouse and I wanna get the Vector3 position of camera that has blue screen”
Basically, I want to offset viewport camera depending to mouse so viewport gui baseplate would look the same as world baseplate even if it’s gonna move to the left or right or any position on the screen.
Imagine you have a viewport GUI with baseplate inside that has 1 scaling on x and y and 0.5 anchor point on x and y. This viewport GUI follows the mouse, and whatever position the mouse has, you have to make so viewport GUI look identical to the normal screen.