Wind Shake: High performance wind effect for leaves and foliage

Ha. Nevermind I literally just figured it out. If anyone else is reading this with the same question, you have to click on wind direction in your settings and give it a value greater than 0 (which was the default for some reason).
image

3 Likes

Some suggestions for the plugin:

  • The plugin still has all connections and functionality working even when it is closed. This is less than ideal, and when selecting large models with many parts in them can cause lag spikes. This is especially a pain point because it’s a local plugin, meaning to even disable it I have to either delete the plugin files or move it somewhere else on my machine. Not convenient.


    (the plugin cloning an entire section of a map despite being closed)

  • The imported WindShake script has MathWorkspaceWind = true. This is strange, because it means any settings I made using the plugin will just be ignored by default anyway. This took me about 10 minutes to notice, wondering why the trees in my game weren’t moving.

  • The height of the preview window is clamped, for some reason? I don’t understand why even when I scale the plugin bigger, I’m still limited to seeing a tiny view of a large selection of trees.


    (large window, >half of it totally empty space)

Have you found a fix for this? I also agree that it seems unrealistic.

When I set the winds to around 40 speed and the wind strength to 3 it looks nice like strong winds but as soon as I get within a certain distance between my character and the tree it begins to “jitter” and shake literally but as soon as I step a bit back or forward it returns to normal.

A note to this is I only see this happen when I have Roblox wind enabled alongside Windshake, so that might be the issue. But yet again, the trees only begin to move when Roblox wind is on.

1 Like

Additional note… I turned off Roblox’s wind and it still does the same thing… jittering. Is there any fix to this? I need higher wind speeds for my game and the only way I can somewhat achieve that is by setting the wind power to over 0.3 @boatbomber

having an issue where things tagged aren’t affected (some are, some aren’t)

I followed all of the steps but it seems to have like a laggy effect when rotating, does anyone know how to fix this?

1 Like

Added windshake yesterday and was working fine. Today i was testing and most of the trees and grass are blinking! LOL

1 Like

could you share your code, idk how to make mine stop working and resuming

Sorry for the late reply. Sure! It’s thankfully simple to setup and both modules work well together.

Breakdown

Firstly we need our variables for each module & the zone we’re using to track.

--// Modules used
local WindShake = require(script.WindShake)
local ZonePlus = require(script.Zone)

-- // Get container
local WindZoneContainer = workspace.WindZone

-- // Construct Zone
local MainZone = ZonePlus.new(WindZoneContainer)

Next, we have to construct the connections for entering and exiting the zone we’ve created. When entering the zone, we can pause the WindShake effect using the Pause() function if the WindShake module is currently running.

--// Construct Zone Connections
MainZone.localPlayerEntered:Connect(function()
	if WindShake.Running then
		WindShake:Pause()
	end
end)

Finally, when exiting the zone, we can check if the WindShake module has been initialized. If it hasn’t, initialize. If it has, resume.

MainZone.localPlayerExited:Connect(function()
	--// Check if WindShake has ever been initialized. If it has, resume. Otherwise initialize
	if not WindShake.Initialized then
		WindShake:Init({MatchWorkspaceWind = true})
	else
		WindShake:Resume()
	end
end)

The WindShake effect should now pause and resume based on entering and exiting a designated zone. Hope this helps! :smile:

Full Code
--// Modules used
local WindShake = require(script.WindShake)
local ZonePlus = require(script.Zone)

-- Get container(s)
local WindZoneContainer = workspace.WindZone

--// Create zone
local MainZone = ZonePlus.new(WindZoneContainer)

--// Construct Zone Connections
MainZone.localPlayerEntered:Connect(function()
	if WindShake.Running then
		WindShake:Pause()
	end
end)

MainZone.localPlayerExited:Connect(function()
	--// Check if WindShake has ever been initialized. If it has, resume. Otherwise initialize
	if not WindShake.Initialized then
		WindShake:Init({MatchWorkspaceWind = true})
	else
		WindShake:Resume()
	end
end)

--// Initialize on join (optional)
WindShake:Init({MatchWorkspaceWind = true})
Video

https://www.youtube.com/watch?v=Wv6A2c9a3sw

1 Like

Hi
Smoothly updating the properties seems to cause jittering problems on the meshes.

My guess is that it constantly re-initializes the CFrame once the attributes are changed. Ideally it shouldn’t reset those, but just proceed the movement where it’s currently at, and use a faster speed/updated wind direction.

Here’s the localscript I’m using for the smooth change:

--[[
	Realistic global wind gusts (strength changes).
    For grass terrain wind effect, also the custom WindShake reacts to this (realism)
    src: https://create.roblox.com/docs/environment/global-wind
]]
local gustCycleDelay = 4 -- Max duration between gust cycles in seconds
local gustCycleDuration = 3.5 -- Duration of each gust cycle in seconds

-- During each gust cycle, a portion of "gust" will be added to "baseWind" in a ramped fashion
local baseWind = Vector3.new(5, 0, 2) -- Base wind speed and direction
local gust = Vector3.new(5, 0, 5) -- Gust speed and direction
local gustIntervals = 100 -- Number of iterations used to calculate each gust interval
local dg = gustCycleDuration / gustIntervals
local dgf = dg / gustCycleDuration

-- Set global wind to base wind initially
workspace.GlobalWind = baseWind

-- Wait delay amount before starting gusts
task.wait(gustCycleDelay)

while true do
	for i = 1, gustIntervals do
		local f = math.sin(math.pi * dgf * i) -- Use sin() function to ramp gust
		workspace.GlobalWind = baseWind + f * gust -- Set global wind to base wind + gust
		task.wait(dg)
	end
	workspace.GlobalWind = baseWind -- Reset global wind to base wind at end of gust cycle
	task.wait(math.random() * gustCycleDelay) -- Wait a random fraction of delay before next gust cycle
end

Thanks

I downloaded the module, set up a localized controller and only half of the parts tagged with ‘WindShake’ actually moved properly. I bought and downloaded the plugin in hopes that I scripted something wrong and the plugin would properly do it for me, but still, no.

Is this plugin outdated or am I doing something wrong?
(This is just a screenshot of the options, when playing the game it does not work either. The preview works in the plugin window, though.)

1 Like

im not familiar with this module or plugin, but you might want to check if streaming enabled is causing issues. In 2021 when this was released, streaming enabled was not default for new baseplate, now it is.

Heads up, if anyone’s experiencing crashing in their game, it might be this module. I have a sort-of hacky custom camera tween for when a player spawns in (tween from overhead view to regular player camera view), and it was sometimes crashing. I tracked it down to the VectorMap module, in which the binary search’s while loop (on line 203 for me) was exhausting script allowed execution time each frame.

The crash was so powerful that it caused many beta tester’s pcs and developer’s studios to crash before the error could be properly logged in the Client crash logs or studio’s output.

EDIT (IMPORTANT): I’ve done some more digging and the player’s character was getting teleported away like, 25 trillion studs from the center. So yeah, the precision errors from that was probably causing the vectormap to crash the client. Though, I will say, I think that precision error should be taken into account especially when it risks hard-crashing the player.

Can support for models come, edit the pivot point of the model, to allow for grouped leaves!

Why do I have to pay $1 for the plugin?

i ran into this too, the first time studio froze but the second time i caught this error message which seems slimilar to yours

im not exactly sure how it errors since the first time i didn’t do anything in the game, but it might be related to the camerashake module by sleitnick since the second time there was a screenshake right before the crash.

the weird thing is though is that the second time nothing in the map was utilizing the module, but a consistent way to replicate the error is to teleport your character to some math.huge location

UPDATE: I think i fixed it
setting the char’s rootpart to math.huge no longer crashes my game, i simply added a magnitude check to the function

Yes this is the main issue I have faced, though it’s not boat’s fault and it’s quite unfortunate.

If only Roblox gave us more tools to manipulate the lighting….
We would be able to make it so the shadows don’t move which would be a lot better. A shame.

I have made a similar system from scratch that has been tested from the bottom up for performance.
There are two options in this resource, a server sided script, and a local script you place inside starter player

Mine is based off the same open sourced algorithm with some key differences, in addition you have the option to sway trunks as well as leaves! Not to mention there are 40 tree models half of which have been uploaded by me, so check it out!
The trunk and leaf animations go really well together!

2 Likes