Thread: Model tilting
View Single Post
10-28-13, 08:09 AM   #36
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Resike View Post
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:
  1. local function OnUpdate(self, elapsed)
  2.     local x, y = GetCursorPosition()
  3.     local limit = false
  4.     local pitch = self.pitch + (y - self.y) * INCREMENT_RADIAL
  5.     if pitch > PITCH_LIMIT or pitch < - PITCH_LIMIT then
  6.         limit = true
  7.     end
  8.     if limit then
  9.         local rotation = format("%.0f", math.abs(math.deg(((x - self.x) / 64 + model:GetFacing())) % 360))
  10.         if rotation ~= format("%.0f", math.abs(math.deg(model:GetFacing()) % 360)) then
  11.             model:SetRotation(math.rad(rotation))
  12.         end
  13.     else
  14.         local yaw = self.yaw + (x - self.x) * INCREMENT_RADIAL
  15.         self:SetOrientation(self.distance, yaw, pitch)
  16.     end
  17.     self.x, self.y = x, y
  18. end

Last edited by Resike : 10-28-13 at 08:47 AM.
  Reply With Quote