|
| 13 Feb 2016 02:44 PM |
local ContextService = game:GetService("ContextActionService") local RunService = game:GetService('RunService')
local Player = game:GetService('Players').LocalPlayer local Camera = workspace.CurrentCamera local Mouse = Player:GetMouse() Camera.CameraType = 'Scriptable'
local Target = workspace:WaitForChild('Part') local RightHolding = false local Dampining = 0.01 local Direction = 1 local Index = 0
local function RightChanged(ActionName, ActionInputState, ActionInputObject) if ActionInputState == Enum.UserInputState.End then RightHolding = false elseif ActionInputState == Enum.UserInputState.Begin then RightHolding = true end end
local DeltaMouse = 0 local LastMouse = 0
RunService.RenderStepped:connect(function() DeltaMouse, LastMouse = LastMouse - Mouse.X, Mouse.X local OldIndex = Index
if RightHolding then Index = Index + (DeltaMouse * 0.005) if Index > OldIndex then Direction = 1 elseif Index < OldIndex then Direction = -1 end end Index = Index + (Dampining * Direction) Camera.CFrame = CFrame.new(Target.Position) * CFrame.Angles(0, Index, 0) * CFrame.new(0, 2.5, 4.5) * CFrame.Angles(math.rad(-20), 0, 0) end)
ContextService:BindAction("RightChanged", RightChanged, false, Enum.UserInputType.MouseButton2)
smite me down god |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2016 02:56 PM |
I cut down usage by making deltamouse event oriented but it still gets up to lile 1.5%... Anyone got some suggestions?
smite me down god |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
| |
|
|
| 14 Feb 2016 04:11 PM |
This bit is also quite a bit of computation and table lookups to do every render frame:
Camera.CFrame = CFrame.new(Target.Position) * CFrame.Angles(0, Index, 0) * CFrame.new(0, 2.5, 4.5) * CFrame.Angles(math.rad(-20), 0, 0)
See if you can't simplify that math |
|
|
| Report Abuse |
|
|
|
| 14 Feb 2016 04:13 PM |
Maybe try changing RenderStepped to HeartBeat?
|
|
|
| Report Abuse |
|
|