Creating Locations - Valheim-Modding/Wiki GitHub Wiki

Page is work in progress

Some notes on ZoneSystem.ZoneLocation fields

ZoneLocation.minAltitude & maxAltitude

The y coordinates are not the value used for these fields. The game puts sea level at y = 30 and then calculates these fields relative to that y value.

minAltitude and maxAltitude are checked after subtracting water level

So:

  • minAltitude = 0 → At sea level (Y = 30)
  • minAltitude = 5 → 5 meters above water (Y = 35)
  • minAltitude = -5 → 5 meters below water (Y = 25)

ZoneLocation.slopeRotation

When enabled, the spawned location will align its local +Z axis (forward direction) to the downhill slope of the terrain.

How it works:

  • The terrain slope is sampled around the spawn point.
  • A forward vector is created from the slope direction (XZ plane only, Y ignored).
  • The object’s rotation is set so its local forward faces this vector.
  • The final rotation is snapped to the nearest 22.5° increment for consistency.

Practical notes:

  • Make sure your prefab’s blue arrow (local +Z axis) in the Unity editor points in the direction you want to face downslope.

TerrainModifier.m_sortOrder

Controls the order in which terrain modifications are applied when multiple modifiers overlap. Lower values are applied first.

Sorting priority (in order):

  1. Non-player modifications before player modifications (m_playerModifiction = false first)
  2. Lower m_sortOrder before higher
  3. Earlier creation time before later
  4. Closer to world origin before farther

Practical use:

  • Set a lower m_sortOrder on your location's main ground-leveling modifier so it applies before decorative elements
  • If a smaller modifier (like a rock cluster) should carve into a larger flattened area, give the larger area a lower sort order
  • Default value is 0 — use negative values to ensure your modifier runs before most others

Example: A location with a main platform (m_sortOrder = -1) and decorative dirt patches (m_sortOrder = 0) ensures the platform flattens first, then the patches paint over it.