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.
// 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
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
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):
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
- The map's wind is in the Look panel.
- 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.
- In Play here, the Cheats panel's Wind sets Strength and Towards for everyone.
Reference
wind | Default | What it does |
|---|---|---|
sway | 1 | How much it sways; 0 for none |
stiffness | 0.4 | 0 soft to 1 stiff |
waves | 1 | How much it joins the waves rolling downwind |
flutter | 0.3 | Tips shivering in a strong wind |
lean | 1 | Leaning downwind as the wind gets up |
speed | 1 | How fast it sways |
sheen | 0.3 | Lighter tips as blades lie over: what shows wind from above |
WindGust | Default | |
|---|---|---|
radius | Cells | |
strength | 1 is a gale (held to at most 3) | |
around | outwards | Degrees it blows towards; a ring outwards from the middle when left out |
lasts | 0.6 | Seconds |
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.