|
so in studio i changed my camera to attach to a part every 1/60th of a second instead of what was 1/30th and then the camera was smooth on the studio version then i used normal roblox and it was still jittering why? |
|
|
WrathsongJoin Date: 2012-07-05 Post Count: 22393 |
if you use renderstepped it should be fine |
|
|
well it's not for some odd reason? |
|
|
Be careful of how much you do in that 1/60th of a second. If you consider that 1/60th of a second will be around 0.166 and you are running lots of code, you may be trying to do 0.17 seconds worth of stuff in 0.166 seconds, which would cause it to fall behind.
|
|
|
You can find how long a chunk of code takes to run:
tick1 = tick()
--code
tick2 = tick()
print(tick2 - tick1)
|
|
|
so how am I going to make it 1.7 seconds or something? do renderstepped then wait? or something |
|
|
You want to make it less than 0.0166 seconds for the code to run. Your options are to increase the efficiency of the code, or to use Heartbeat instead (0.0333 seconds), which would give the code more time to run.
|
|
|
how do I use heartbeat? and would it fix my camera stutter problem? |
|
|
Use the tick thing I said to find out how long the code takes to run first.
|
|
|
can you find out how long this runs? I can't figure out I'm dumb :P
script.Parent.MouseButton1Down:connect(function()
script.Parent.Visible = false
script.Parent.Parent.MiniGuiFolder["<"].Visible = false
script.Parent.Parent.MiniGuiFolder[">"].Visible = false
script.Parent.Parent.MiniGuiFolder.Frame2.Visible = false
script.Parent.Parent.MiniGuiFolder.TextLabel.Visible = false
script.Parent.Parent.MiniGuiFolder.text2.Visible = true
local player = game.Players.LocalPlayer
wait(0.3)
game.Workspace[player.Name..'Figure'].Humanoid.Health = 100
game.Workspace[player.Name..'Figure'].Humanoid.MaxHealth = 100
local target = workspace[player.Name.."Figure"].Torso
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
game:GetService("RunService").RenderStepped:connect(function()
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(-95, 0, 0)
* CFrame.new(0, 0, 25)
end)
end) |
|
|
Run this without the RenderStepped part:
tick1 = 0
tick2 = 0
tick1 = tick()
camera.CoordinateFrame = CFrame.new(target.Position)
* CFrame.Angles(-95, 0, 0)
* CFrame.new(0, 0, 25)
tick2 = tick()
print(tick2 - tick1)
|
|
|
its not printing anything |
|
|
Ok, just try changing:
game:GetService("RunService").RenderStepped:connect(function()
to
game:GetService("RunService").Heartbeat:connect(function()
|
|
|
|
now its stuttering on both ends not just the real client (if you read you would see I said it is only stuttering on the roblox client not roblox studio) |
|
|
In that case there's not a lot you can do about the original stutter, just change back to Renderstepped.
|
|
|
|
that's sad then because how can other games have such smooth cameras? and it is a localscript
Can you tell me what is wrong with the camera if you were to play the game? It should be on my profile, Battle Bloxors |
|
|
Why does it even connected when the MouseButton1Down event is called? |
|
|
because it's a play button |
|
|
so i just learned that for some odd reason only 1 person gets a camera attached to their npc thing and that for some odd reason the other player when they click . on their keyboard it pops up with the gui thats supposed to only pop up for them |
|
QuentyJoin Date: 2009-09-03 Post Count: 9316 |
Use Part:GetRenderCFrame() instead of Part.CFrame
ROBLOX interpolates parts in server/client mode to get a smooth rendering (i.e. physics aren't sent at 60 FPS, but things render at 60 FPS). Thus, you need :GetRenderCFrame().
|
|
|
Where do I put the Part.GetRenderCFrame() thing?
Also thanks for replying quenty ;) |
|