The Wind Manager is a script for Unity that controls the wind direction and force and applies them to the rigidbodies in the scene. It also includes turbulence, gusts, and dynamic wind cycles that can be adjusted.
To use the Wind Manager in your Unity project, follow these steps:
- Download the
WindManager.csfile. - Import the script into your Unity project by placing it in any folder in the
Assetsdirectory. - Attach the Wind Manager script to a game object in your scene.
- Adjust the public variables in the Inspector to customize the wind behavior.
The Wind Manager script includes the following public variables that can be adjusted in the Inspector:
baseDirection: aVector3that sets the default wind direction.baseForce: afloatthat sets the default wind force before variation.minForce: minimum wind force allowed.maxForce: maximum wind force allowed.forceMode: theForceModeused when applying wind to rigidbodies.
dynamicWind: enables animated wind direction and strength based on time of day.dayLengthInSeconds: sets how long a full wind cycle lasts.forceOverDay: anAnimationCurvecontrolling how wind force varies over the day.yawOverDay: anAnimationCurvecontrolling how wind yaw (rotation) changes over the day.
applyTurbulence: enables 3D noise-based turbulence.turbulenceIntensity: multiplier for turbulence strength.turbulenceScale: frequency scale of the turbulence.turbulenceOctaves: number of noise layers used for turbulence detail.
gustsEnabled: enables short bursts of stronger wind.gustIntensity: how strong gusts are relative to base force.gustFrequency: how often gusts may occur.gustDuration: duration of each gust event.gustEnvelope:AnimationCurvedefining the gust strength shape over time.
dynamicRigidbodies: whether to re-scan the scene for rigidbodies at runtime.rescanInterval: how often to refresh the list of targets (if dynamicRigidbodies is true).affectedLayers: a layer mask defining which rigidbodies are affected.areaLimited: if true, wind only applies inside a specified region.areaBounds: aBoxColliderused to define the wind-affected area.
noiseSeed: optional seed for deterministic turbulence and gust behavior.
To apply the wind force to a specific rigidbody:
- Add a
Rigidbodycomponent to the GameObject. - Ensure the Rigidbody is non-kinematic.
- Place the GameObject in the scene.
- Run the game. The Wind Manager will apply wind forces automatically.
- The Wind Manager only affects rigidbodies that are not marked as kinematic.
- If
dynamicRigidbodiesis set to true, the script will re-scan all rigidbodies in the scene every few frames. This may impact performance in large scenes. - The wind direction, turbulence, and force are recalculated and applied in
FixedUpdate, making the behavior frame-rate independent. - The
GetCurrentWindDirection()andGetCurrentWindForce()methods can be called at runtime if other scripts need to react to the wind state.
This project is licensed under the MIT License - see the LICENSE.md file for details.