Hello, I am still relatively new to the world of programming, I at the moment pick apart code till it works the way I want it to. So, bear with me. (I honestly cannot tell if they are being affected or not, but my results point to they are)
-
What do you want to achieve?
Fix the flares from being affected by high FPS.
(see “@ 60 FPS vs @ 240 FPS” [NO 60FPS TICK] for reference) -
What is the issue?
Movement, possibly despawn (lifetime) and FXCounter are being affected by FPS. -
What solutions have you tried so far
Added *60 -60 +60 to the “lastTick” variable and changed everything to delta time, yet I see no change. -
My findings:
Initial velocities: 259.633544921875 / 259.7339782714844 / 259.54248046875
@ 60 FPS | no 60fps tick.
Initial velocities: 258.828125 / 259.55560302734375 / 258.6429138183594
@ 60 FPS yes 60fps tick.
–
Initial velocities: 262.847412109375 / 262.4277038574219 / 262.4923095703125
@ 240 FPS no 60fps tick.
Initial velocities: 262.29150390625 / 262.7029724121094 / 262.7797546386719
@ 240 FPS yes 60fps tick. -
The code:
local gravity = Vector3.new(0, -workspace.Gravity / 10, 0)
local lastTick = tick()
rs.RenderStepped:Connect(function()
local t = tick() - lastTick
lastTick = tick()
local timedGravity = gravity * t
for _,v in pairs(cs:GetTagged("FlareAttachment")) do
local movement = v.Velocity.Value.Magnitude * t * 1.05
v.FXCounter.Value = v.Lifetime.Value * math.random()
if v.Lifetime.Value > 0 then
v.Lifetime.Value = v.Lifetime.Value - t
v.Smoke.Enabled = true
v.Fire:Emit(v.FXCounter.Value)
else
v.Smoke.Enabled = false
return cs:RemoveTag(v, "FlareAttachment"), game.Debris:AddItem(v, 30)
end
v.WorldCFrame = v.WorldCFrame + (v.Velocity.Value * t)
v.AttachmentL.Value.WorldCFrame = v.WorldCFrame + Vector3.new(0,0,-.5)
v.AttachmentR.Value.WorldCFrame = v.WorldCFrame + Vector3.new(0,0,.5)
local dragFactor = 1.05
local drag = dragFactor * t + 1
v.Velocity.Value = (v.Velocity.Value + timedGravity) / drag
print(v.Velocity.Value.Magnitude)
end
end)