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.