So there is something I don’t understand, inside my MouseEnter event I have this code run, which I ripped from another tutorial page.
viewportCamera.FieldOfView = 40
local cameraGoal = {
CFrame = CFrame.new(Vector3.new(0, 6, 4), part.Position)
}
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(viewportCamera, tweenInfo, cameraGoal)
tween:Play()
I don’t understand how this rotates the camera, shouldn’t it just put the camera to that X, Y, and Z on a 2D view? Because the same code runs after a 2 second wait (different dimensions) but it shows it on a 2D plane, yet when the mouse enter event runs it actually rotates the camera to view the top of this part.
I want the rotate to happen, but I can’t seem to get the camera closer to the part, if I lower the values used in the tween then the rotate doesn’t happen. I tried changing the camera FieldOfView on MouseEnter, but it only changes it once I return back to my original camera view via the MouseLeave event. Any ideas how to fix this?
local TweenService = game:GetService("TweenService")
task.wait(2)
print("waited")
local viewportFrame = script.Parent;
part = workspace.Hair
part.Position = Vector3.new(0, 0, 0)
part.Parent = viewportFrame
local cameraOffset = Vector3.new(0, .5, 2)
local viewportCamera = Instance.new("Camera")
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.Parent = viewportFrame
viewportCamera.CFrame = CFrame.new(Vector3.new(0, .5, 2), part.Position)
local rotatedCFrame = CFrame.Angles(math.rad(15), 0, 0)
rotatedCFrame = CFrame.new(part.Position) * rotatedCFrame
viewportCamera.CFrame = rotatedCFrame:ToWorldSpace(CFrame.new(cameraOffset))
viewportFrame.MouseEnter:Connect(function(x, y)
viewportCamera.FieldOfView = 40
local cameraGoal = {
CFrame = CFrame.new(Vector3.new(0, 6, 4), part.Position)
}
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(viewportCamera, tweenInfo, cameraGoal)
tween:Play()
end)
viewportFrame.MouseLeave:Connect(function(x, y)
local cameraGoal = {
CFrame = CFrame.new(Vector3.new(0, .5, 2), part.Position)
}
local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tween = TweenService:Create(viewportCamera, tweenInfo, cameraGoal)
tween:Play()
end)