generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

How on earth does those code get to 2% usage?

Previous Thread :: Next Thread 
checkplate is not online. checkplate
Joined: 05 Jan 2016
Total Posts: 1379
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
checkplate is not online. checkplate
Joined: 05 Jan 2016
Total Posts: 1379
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 is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
13 Feb 2016 03:07 PM
because, renderstepped
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
14 Feb 2016 04:09 PM
^
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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
cheesecake123456 is not online. cheesecake123456
Joined: 01 Jun 2009
Total Posts: 1529
14 Feb 2016 04:13 PM
Maybe try changing RenderStepped to HeartBeat?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image