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

droptofloor

From Quake Wiki

Revision as of 12:13, 1 August 2023 by Boondorl (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

float droptofloor()

Usage

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

Returns TRUE if the entity was placed on valid ground.

Example

// 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;
}