I found this script at https://www.wowinterface.com/forums/showthread.php?t=58245
local function SetCameraZoom(level)
local zoom = GetCameraZoom()
local delta = zoom-level
if delta > 0 then
CameraZoomIn(delta)
else
CameraZoomOut(-delta)
end
end
It works for the most part, but I’m running into situations where it will trigger twice (I think?) and zoom more than intended. Is there a way to specify a camera zoom distance without calling the CameraZoomIn and CameraZoomOut functions? I know you can use SaveView(), but you have to manually set your camera in-game before it will function as intended.
This is the offending script:
local function OnEvent(self, event)
if IsInInstance() then return end
if IsMounted() or UnitInVehicle("player") then
SetCVar("test_cameraOverShoulder", 0)
SetCameraZoom(15)
else
SetCVar("test_cameraOverShoulder", 1)
SetCameraZoom(7)
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED")
f:RegisterEvent("UNIT_ENTERED_VEHICLE")
f:RegisterEvent("UNIT_EXITED_VEHICLE")
f:SetScript("OnEvent", OnEvent)
It appears that UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE cause SetCameraZoom’s unintended effects. Being able to save specific camera settings to call instead of using SetCameraZoom would make this problem irrelevant.