Okay, thanks for you help i managed to do it, however the tilting seems kinda weird, also the model sometimes radnomly flips 180 degrees when its tilted 0 or 90 degrees. Not sure whats causing this.
Here is my code:
Lua Code:
local frame2 = CreateFrame("Frame", nil, UIParent)
frame2:SetPoint("Center", - 128, 0)
frame2:SetWidth(512)
frame2:SetHeight(512)
frame2:SetAlpha(1)
local model2 = CreateFrame("PlayerModel", nil, frame)
model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
model2:SetAlpha(1)
model2:SetAllPoints(frame2)
model2:SetCustomCamera(1)
local x, y, z = model2:GetCameraPosition()
local r = math.sqrt((x * x) + (z * z))
print(x, y, z, r)
local degree = 90
local slider = CreateFrame("Slider", nil, UIParent, "OptionsSliderTemplate")
slider:ClearAllPoints()
slider:SetPoint("Center", UIParent, "Center", 0, 300)
slider:SetMinMaxValues(90, 180)
slider:SetValue(90)
slider:SetValueStep(1)
slider:SetScript("OnValueChanged", function(slider, value)
degree = value
ModelBasics_UpdateModel2()
end)
function ModelBasics_UpdateModel2()
--model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
--model2:SetRotation(math.rad(0))
model2:SetCustomCamera(1)
local xx = math.pow(math.sin(math.rad(degree)), 2) * r
local zz = math.pow(math.cos(math.rad(degree)), 2) * r
model2:SetCameraPosition(xx, y, zz)
--model2:SetAllPoints(frame2)
end
ModelBasics_UpdateModel2()