RUSTICDOCSSearch documentation

Configure scene wind

  1. In Scene Explorer, choose + Add → Wind. The new entry appears under Environment. New scenes start with Sky and Fog.
  2. In Wind properties, set the two Strength values in metres per second. Equal values give a steady speed. Enter a lower and upper value from 0 to 100 for smoothly varying gusts.
  3. Set the two Direction bearings from 0° to 360°. Bearings describe where the air travels. 0° points toward world −Z and 90° toward +X. Equal bearings give a fixed direction. A range of 350° to 10° crosses north.
  4. Add Clouds to see the layer move during Play. To move a primitive, give it Wind drag above zero in Properties and clear Anchored. Start with a drag coefficient of 1 and a wind speed of 20 m/s for a simple test. Play should show the primitive drifting downwind.

Wind applies quadratic drag based on the air velocity relative to the body, its projected area, and a mass estimate from its collision bounds. The engine assumes one world unit is one metre and uses a uniform material density for that estimate. It simulates translational drag for unanchored primitives with a positive coefficient. Imported meshes can read and react to wind using scripts. Cloud lighting uses sunward density samples so bright edges and shadowed interiors change with sun direction.

Read and change wind from scripts

Attach an object component script to a primitive. This Lua example configures a gusting wind, enables drag on the attached primitive, and reads the current world-space velocity in metres per second.

lua
return {
  Start = function()
    Game.scene.setEnvironment({
      wind = { enabled = true, strength = { 5, 12 }, direction = { 350, 10 } }
    })
    rustic.EditAttribute("WindDrag", 1)
  end,
  FixedUpdate = function()
    local velocity = Game.scene.getEnvironment("wind_velocity")
    -- velocity[1], velocity[2], velocity[3] are world X, Y, and Z.
  end
}

Use Game.scene.getEnvironment("wind") to read the configured wind or get a null value when there is no Wind entry. Use Game.scene.setEnvironment({wind: {strength: [8, 8]}}) in JavaScript to update just the speed. Game.scene.getEnvironment("wind_velocity") returns zero when wind is absent or disabled. Use wind: null in a settings object to remove Wind. In C, configure wind with Game.scene.setWind(true, 5, 12, 350, 10) and read the velocity with Game.scene.getEnvironment("wind_velocity"). Apply settings in the editor and save to persist them across Play sessions.