Table of Contents

Method PlaceItemOnGround

Namespace
GrindFest
Assembly
GrindFest.dll

PlaceItemOnGround(ItemBehaviour, Vector3, string)

Put a spawned item down on ground that has actually been checked, with its physics at rest. Use this instead of writing item.transform.position = ... directly.

protected Vector3 PlaceItemOnGround(ItemBehaviour item, Vector3 target, string what = null)

Parameters

item ItemBehaviour
target Vector3
what string

Returns

Vector3

Remarks

SpawnItem(string, int, ItemRank, int) goes through DropAround(Vector3, float), which is a THROW and not a placement: +2.5 m of height, a random 0.5 m offset, an upward impulse and a random torque. Writing transform.position afterwards moves the object but leaves all of that in place, so the item arrives at its target already spinning and already moving - and when the target sits exactly at terrain height that is a coin flip between "rests" and "slides, tunnels or falls through".

Measured 2026-09-16: PlantAndWaterInPot failed in ~4% of runs because the planter pot ended up 8.6-11.8 m below the hero, while every passing run had it at the hero's own height. The bot API searches with CropContainerBehaviour.FindNearest(..., maxDistance: 10f), so the pot was simply no longer in range, and the test failed with "Action returned Failed: Water pot" - a message that names neither the pot nor the fall. Failing runs: crop planted at y = 0.67, 2.40 and -0.88 against a hero at y = 10.96. The product has suspected this for a while: DropAround carries the comment "bug: i think that calling this on chests at the edge will cause items to fall through".

The ground is looked up rather than assumed, because the spot a test wants is usually 1-2 m in front of the hero and a MapMagic tile boundary or a hole there is not something the hero's own readiness gate (WaitForTerrainAt(Vector3, float, bool)) can see.

The lookup itself was wrong too, and fixed 2026-09-20: it asked with ~0 and took whichever hit the physics engine wrote first. At the farming spot that was the Darkness backdrop plane at y=8.77 instead of the terrain at 11.37, so the pot was teleported 2.5 m into the ground - three FarmingTests then failed with "Expected container.IsPlanted but got state 'Empty'", which names neither the pot nor the fall. It is now a layer-filtered lookup (TryGetClearGround(Vector3, out Vector3, out string, Transform): ground layers only, topmost hit, and a spot with no room is rejected and the placement nudged).