Originally Posted by Resike
My other tought to fix it was when "pitch >= math.pi / 2" or "pitch <= math.pi / 2" then rotate the model instead of changing the camera's location, i had no time to test it yet tho.
|
I tried this method now, and i think this is the smoothest way to solve this stuck issue. Here is the updated OnUpdate function (degree precisely):
Lua Code:
local function OnUpdate(self, elapsed)
local x, y = GetCursorPosition()
local limit = false
local pitch = self.pitch + (y - self.y) * INCREMENT_RADIAL
if pitch > PITCH_LIMIT or pitch < - PITCH_LIMIT then
limit = true
end
if limit then
local rotation = format("%.0f", math.abs(math.deg(((x - self.x) / 64 + model:GetFacing())) % 360))
if rotation ~= format("%.0f", math.abs(math.deg(model:GetFacing()) % 360)) then
model:SetRotation(math.rad(rotation))
end
else
local yaw = self.yaw + (x - self.x) * INCREMENT_RADIAL
self:SetOrientation(self.distance, yaw, pitch)
end
self.x, self.y = x, y
end