For the purpose of this question, assume all scripts are LocalScripts being ran clientside.
I am attempting to lower the Activity % of a vehicle system I am working on in the Script Performance tab. Currently it runs at about 2.5% activity max. It runs so high because of constant raycast coming from each wheel to determine which material it is driving over for various trail/particle effects. These raycasts are coming from a Heartbeat connect like so:
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
for i, wheel in wheels:GetChildren() do
--Do raycast for material
--Enabled/disable trails/particles accordingly
end
--Do other stuff for system as well
end)
I read up on Parallel scripting and discovered the documentation says that the more actors I use the more efficient I can make my system. I though I could have each wheel do its own raycast in a separate Actor and thus separated it out of the Main system. So each wheel had its own script inside its own actor and looked more like this:
game:GetService("RunService").Heartbeat:ConnectParallel(function(deltaTime)
--Do raycast for individual wheel
task.synchronize()
--Enable/disable trails/particles accordingly
end)
And the main system had its own script and its own actor and looked like this
game:GetService("RunService").Heartbeat:ConnectParallel(function(deltaTime)
--Do stuff for system
end)
So the vehicles had 5 actors total. 1 for each wheel, 1 for the main system. But when checking how it was running in the Script Performance Tab the Activity % was WAY higher than it was before.
The wheel actors themselves taking up 5% Activity and the Main System still taking about 2%!
So my question is: Does the Script Performance Tab take Parallel Scripting into account when determining the Activity %?
If so, what am I doing wrong to decrease the performance cost?
And if not, what can I use instead to determine the performance cost through parallel scripting?