Knowledge from the fieldRedM

`PLACE_OBJECT_ON_GROUND_PROPERLY` removes Z-tuning hell — set heading first, then place, then freeze

learning:18

PLACE_OBJECT_ON_GROUND_PROPERLY removes Z-tuning hell — set heading first, then place, then freeze

Context

You're spawning props at world coords (safes, crates, kegs, anvils — anything that should sit on the floor). The Z component is annoying: indoor floor heights vary, mapdata Z near a door isn't the same as 1m inside, and your testers report props floating, clipping into the floor, or stuck on the ceiling depending on which shop they're in.

The pattern that just works

-- REQUEST_MODEL + wait
RequestModel(model); while not HasModelLoaded(model) do Wait(50) end

-- CREATE_OBJECT at approx coords (Z is just a streaming hint)
local entity = CreateObject(model, x, y, z, false, false, false, false, false)

-- Heading FIRST, before ground-snap (so the prop's footprint is oriented when it samples the floor)
SetEntityHeading(entity, heading)

-- PLACE_OBJECT_ON_GROUND_PROPERLY (0x58A850EAEE20FAA3) — Z is now correct
PlaceObjectOnGroundProperly(entity, false)

-- Freeze AFTER ground-snap so the prop stays put
FreezeEntityPosition(entity, true)

SetModelAsNoLongerNeeded(model)

Why heading must precede place

The native samples the prop's collision footprint to find ground. If the prop is rotated after placement, the new orientation may now intersect a wall or hover above an angled surface. Set heading first, snap once, freeze.

Caveat

PLACE_OBJECT_ON_GROUND_PROPERLY requires the streaming around the coords to be loaded. If you call it during resource start before the player is near, it can fail silently and leave Z at the spawn value. Either:

  1. Use a small delay / streaming-ready check before snapping for prop-placements far from the player.
  2. Snap from a CreateThread that runs after the player is near (interior streaming usually triggers within ~30m).

Companion config field

Add an optional snapToGround = true flag to your location config so individual entries can opt out (e.g. a safe placed on a desk where you DO want manual Z). Defaulting it to true removes 90% of "props are floating" tickets.

Linked natives

  • PLACE_OBJECT_ON_GROUND_PROPERLY (0x58A850EAEE20FAA3)

Tags: none
Category: uncategorized
Created: 2026-05-01T13:44:14.696Z

Back to documentation