Not sure that it will make a performance difference cuz I'm not sure what the cause is but you could try an approach that doesn't use TweenService like caching the textures and updating by a fixed amount on the OffsetStudsU and OffsetStudsV per frame until you're >= 30 and then reset to 0 (or however your previous implementation rolls over). If TweenService creates a coroutine per tween then it's safe to assume that doing it on a single thread would be more efficient
#Animated Textures on a moving part causes extreme lag
1 messages · Page 1 of 1 (latest)
Ok, well, I had VERY STUPIDLY done that on the server and not the client - pardon me for that, however now there are random FPS drops so it's definitely not optimized
Also, that tween just loops using the tween info settings
Yeah it's still very bad.
Also I already tried this before posting.
TweenService is more efficient unless I was doing it wrong..
hard disagree
I could give it another shot I guess
local runService = game:GetService("RunService")
local connection = nil
local textures = {}
for i, texture in pairs(script.Parent:GetChildren()) do
if texture:IsA("Texture") then
table.insert(textures, texture)
end
end
local function update()
task.wait(0.1)
for i, texture in next, textures do
texture.OffsetStudsU = texture.OffsetStudsU + 0.05
texture.OffsetStudsV = texture.OffsetStudsV + 0.01
end
end
connection = runService.Heartbeat:Connect(update)
script.Parent.Parent.Parent.Destroying:Connect(function()
connection:Disconnect()
end)
@river plinth What are your thoughts?
I would not yield in the update, heartbeat already yields. If you need to run at a rate of a 10th of a second, you should do something like
local runTime = 0
local function update(dt)
runTime += dt
if runTime < 0.1 then return end
runTime = 0
for i, texture in next, textures do
texture.OffsetStudsU = texture.OffsetStudsU + 0.05
texture.OffsetStudsV = texture.OffsetStudsV + 0.01
end
end
I'll check it out tomorrow
Also, the issue comes that the textures cause lag as the segway is being moved, if I hit run it would have no issues
The CPU time spikes from 13ms in the microprofiler to 36ms with the animated texture while the segway is used/moving around
Still very bad