Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

:BindToRenderStep causing major framerate drops?

Asked by 9 years ago

I'm using RunService:BindToRenderStep to make a brick stay relative to the camera, and it works very well but it causes major framerate drops. Like 60 FPS to 25. For some reason, it happens only when you move the camera, and if I zoom out really far from the map, no more framerate drops. Here's the code. It's a module script, but I've tried it out of one and the same thing happened.

local module = {}
local cam = workspace.CurrentCamera
local rightSideOffset = CFrame.new(2,0,-2)
local rightSideRotation = CFrame.Angles(math.rad(90),math.rad(0),math.rad(35))
local runService = game:GetService("RunService")

module.InitiateHUD = function()
    local rightSide = Instance.new("Part", cam)
    rightSide.FormFactor = Enum.FormFactor.Custom
    rightSide.CFrame = cam.CoordinateFrame*rightSideOffset*rightSideRotation
    rightSide.Anchored = true
    rightSide.Transparency = 0.7
    rightSide.Material = Enum.Material.SmoothPlastic
    rightSide.TopSurface = Enum.SurfaceType.Smooth
    rightSide.TopSurface = Enum.SurfaceType.Smooth
    rightSide.Size = Vector3.new(1.5,0.2,3)
    rightSide.CanCollide = false
    runService:BindToRenderStep("positionRightSideHUD", Enum.RenderPriority.Character.Value, function() rightSide.CFrame = cam.CoordinateFrame*rightSideOffset*rightSideRotation end)
end



return module
0
Is the script that calls the function in a loop? User#5978 25 — 9y
0
There is another script that uses this module and runs the function, InitiateHUD. dudemanjude 10 — 9y
0
The :BindToRenderStep function is positioning the block relative to the camera every frame. That's what's looping. dudemanjude 10 — 9y
0
That's why, looping anything that changes something like a position to something that changes so smelly is the problem User#5978 25 — 9y
0
I don't think so. If I make the part fully transparent, no more framerate drops. I put GUI's on that part and they work fine, without framerate drops, only if the main part is fully transparent. dudemanjude 10 — 9y

Answer this question