Introduce an interactive grass system!

Would love it if you made this open source :smiley:

3 Likes

Here you all are - I’ve commented throughout the code so you can understand what it’s doing, and if you want to change the values.

I’ve also included settings so you can switch between:

  • tween or LERP
  • updates every frame or after X seconds

If you’re looking for high end devices I recommend running the code as is. If you want it to work for lower-end devices, enable desired interval and/or switch to LERP.

InteractiveGrass.rbxl (513.7 KB)

12 Likes

I actually really appreciate you for making this, I didn’t think grass would be so interesting

2 Likes

Of all the grass, this is certainly one of them :crazy_face:

This is really cool! I’ll have to look at it later. Your optimization scheme sounds interesting. Great work!

1 Like

Thanks! I will have to try this out later, the OP mentioned possibly making a plugin for their grass but i guess not.

1 Like

so where’s the model download?

1 Like

looks better than any roblox grass ive ever seen, same for the interactions. thank you so much.

3 Likes

I’m going to give other noobs a small heads up about this script. I hope i can spare other people some frustration.

If you’ve got a lot of other stuff in the game, the setup part of the script may run before the blades of grass are loaded, which means their attributes wont be set and the script wont work.

two ways to combat this:

  1. add the loop and wait for every descendant of the grassfolder to the top of your setup() function. I think thats performant and wont be a problem but if anyone knows better then please correct me. I’ve not noticed problems.
local function setup()
	local grasstoload = grassfolder:GetDescendants()
	for _,v in pairs(grasstoload) do
		repeat wait() until v
	end
	
	for key, grass in grassfolder:GetDescendants() do -- get the descendants of grassfolder and call them grass
			if grass:IsA("MeshPart") then -- Get all the meshparts (not grassareas or grassclumps) in the grassfolder --
				grass:SetAttribute("OriginalCF", grass.CFrame) -- store their original cframe
				grass:SetAttribute("Bent", false) -- Set them as currently not being bent
			end
		
		
	end
end
  1. WaitForDescendants() this module script which i havent tested myself but seems pretty convenient