Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

droptofloor

From Quake Wiki

float droptofloor()

Usage[edit]

Tries to move an entity to the nearest floor beneath it, up to 256 map units. This is mostly for snapping item and monsters to the ground at map start, but this function shouldn't be called within the initializer functions themselves. Not all entities are guaranteed to be loaded in yet at map spawn, so it's best to wait at least a frame for everything to load in.

Warning: The function assumes that self is the current entity trying to snap to the floor.

Return[edit]

Returns TRUE if the entity was placed on valid ground.

Example[edit]

// This function tries to keep an entity stuck to the ground
float MoveToGround(vector pos)
{
    vector curOrigin = self.origin;
    setorigin(self, pos);
    if (!droptofloor())
    {
        setorigin(self, curOrigin);
        return FALSE;
    }

    return TRUE;
}