Skip to content

Make grass follow the wind ​

Give the map a wind (MapEnvironment.wind): grass sways, leans downwind, and waves roll over a field. Each style responds in its own way through the look's wind group.

ts
// in src/view.ts
import { foliage, type GameView } from '@v12-engine/client'

export const view: GameView = {
	units: { looks: {} },
	world: { environments: { breezy: { wind: { around: 90, strength: 0.6, gusts: 0.3 } } } },
	ground: {
		cellLayers: {
			grass: foliage({
				wind: { stiffness: 0.25, waves: 1.3, sheen: 0.4 }, // a soft meadow, shining as it bends
				styles: { 2: { wind: { stiffness: 0.85, waves: 0.2, flutter: 0.5 } } } // reeds: stiff, their tips shiver
			})
		}
	}
}

Done: on a map with the breezy look, waves of bend roll east over the meadow while the reeds hardly move.

Change the wind from the rules ​

ts
import type { World } from '@v12-engine/engine'

// a storm gets up over 5 seconds on every screen; the fire goes by it too
export const storm = (world: World): void => world.setEnvironment({ wind: { around: 200, strength: 1 } }, { over: 5 })

A gust from an explosion ​

ts
import { defineListener, entityDied, gust } from '@v12-engine/engine'

export const blast = defineListener({
	event: entityDied,
	id: 'mygame.blast',
	run(world, { entity }) {
		// a ring of wind out from where the powder keg was, on the screen of every player who sees it
		if (entity.def.id === 'powderKeg') gust(world, { x: entity.pos.x, z: entity.pos.z }, { radius: 8, strength: 2 })
	}
})

On one screen only (a dragon flying over, seen by this player alone):

ts
import type { GameClient } from '@v12-engine/client'

declare const client: GameClient

client.gust({ x: 40, z: 22 }, { radius: 5, strength: 1.2, around: 45, lasts: 1.5 })

In the editor ​

  1. The map's wind is in the Look panel.
  2. In Grass and bushes › Wind, set Sway, Stiffness, Waves, Flutter, Leans downwind, Speed and Sheen. Slide Preview wind to judge them; it isn't saved.
  3. In Play here, the Cheats panel's Wind sets Strength and Towards for everyone.

Reference ​

windDefaultWhat it does
sway1How much it sways; 0 for none
stiffness0.40 soft to 1 stiff
waves1How much it joins the waves rolling downwind
flutter0.3Tips shivering in a strong wind
lean1Leaning downwind as the wind gets up
speed1How fast it sways
sheen0.3Lighter tips as blades lie over: what shows wind from above
WindGustDefault
radiusCells
strength1 is a gale (held to at most 3)
aroundoutwardsDegrees it blows towards; a ring outwards from the middle when left out
lasts0.6Seconds

gust is told to the players whose team sees its middle or its edge, as a message. It is not saved and changes nothing in the world. At most four gusts blow at once; a new one takes the place of the one nearest its end. Bushes drawn as models follow the layer's wind, not a style's. rotation.faceWind and rotation.leanTo: 'wind' turn grass to the wind as it is laid. Read the wind with client.wind. See Lighting and weather.