I’ve tried adding tick rate so it runs the code less often, however it still doesn’t fix the main issue as it runs at 0.7% script activity rather then the 4% before adding tick rate. The delay also doesn’t help the effect I’m trying to make using the distance value.
I’m running it on RenderStepped and the function is being called from a for loop.
I’m grabbing all the grass from a table using the for loop.
for i = 1, GrassAmount, 1 do
UpdateDistance(i, CameraLocation)
end
If there is a much easier and less expensive way in doing this I’m not sure what it is. This also grabs multiple other table values, not only the grasses position.
Every 5 distance away the grass animation moves slower to drop script activity and once distance is over 40 the grass is moved to a folder in lighting so it can stop affecting script activity.
Client sided activity will only count towards the player’s hardware, so if someone’s computer is not that great performance on client sided scripts will not be that good as well, but games run on a tick loop. Take unity for example, from my experience most things run through the Update function which runs every frame, and as long as you don’t have very complex calculations or very expensive code running every frame, you are most likely fine. I had a similar issue with my first person animated movement which was updated every frame, tested it in different machines and everything was fine.
I do however love the fact you’re adding such optimizations to your game, very unique and not seen that often