Grass System: looking for advice on how to lower script activity

Any progress on lowering the activity?

I have lowered it from 15-17% to 9.5-10.5%
Still working on it, but itā€™s difficult since there isnā€™t many people willing to put time into figuring it out with me. Iā€™m looking into a new way to simulate a similar style with the movement code by changing it so that 6-8 patches of the grass all move in sink, meaning itā€™ll take up less activity since it wonā€™t be individual. However Iā€™ll only pursue it after if it looks as good as the current.

You have an enormous amount of if/elseif statements, is there any way you could reduce on those?
Check out the Benchmark plugin, I think it has a profiler to see which operations in your code take up the most.

I have made changes to it since then. Iā€™ll quickly change them.

Is the grass spawned on the server or client? You can switch to spawning the grass entirely on the client for better activity.

Itā€™s on client, since I didnā€™t want players to see another playerā€™s area of grass which would cause performance issues and wouldnā€™t look right.

Iā€™ve experimented with a new method for the code, which makes the tick rate a lot more smooth and decreased script activity from 9.5%-10.5% to 6%-7.5%. Very close to finalizing it, but obviously the last 2% needed will still take a while to get working.

Any more progress on lowering the script activity?

Iā€™ve gotten it to as low as 5.7%, but Iā€™ve found that it isnā€™t possible for me to lower it anymore as Iā€™m using BulkMoveTo which is the lowest cost way of moving objects from my research.

Iā€™ve moved onto experimenting with finding ways to lower the need to use it. I donā€™t think that Iā€™ll make it into a module script as I donā€™t have anymore patience for this system and need to move forward with what I intended to do after finishing this. When I release the open source it will be the way it works now with little explanation on how it works but rather how to use it.

I am no expert to programming/coding so this system will probably seem flawed to such experts.

Iā€™m delaying its release to add in a stepping feature where when a player steps on the grass it gets flattened for a select time.

It will look good in my opinion, and in theory should reduce the script activity a bit more.

Will you release it soon? Talking about within 3 days

I should be able to get this system done by either tomorrow or the day after. Then Iā€™ll try to quickly write up some comments to explain the important sections of the code so people can change it if they want.

Is there a reason you arenā€™t using the default grass thats available for terrain? Unless you need different variations of grass such as flowers I donā€™t see the need for such levels of customization.

On a side note, do you use an octree system to determine the grass near you to render? Seems like an easy system to clear up some lag.

Side-side note: octrees, depending on how they are implemented, are actually slower than default region3 checks unless youā€™re searching for objects within a >100 radius.

1 Like

The Default Roblox grass, while it is very lag free, the customization and movements are very standard and bland.

I like the idea of being able to trample grass, see it glow at the tip and flow with the areaā€™s wind pressure. My system doesnā€™t perfectly touch it but its still better looking then the roblox default the way I see it.

Also I havenā€™t touched Octrees yet, and donā€™t plan on it until Iā€™ve made some headway on the rest of my project.

1 Like

I couldnā€™t get the step function to work, was a real pain. I open sourced it: Grass System by DylanD319

You should try doing the effects on the client. But if you are then just try using less if statements, for loops, and try deleting it when you are further away from the patch of grass.