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

Editing droptofloor

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''float'' '''droptofloor'''()
+
====Syntax:====
 +
<code>float droptofloor(float yaw, float dist)</code>
  
== Usage ==
+
Tries to "drop" an entity down up to 256 units in a single frame, as if it had fallen due to physics.
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.
+
====Parameters:====
 
+
:<code>yaw</code> - Unused?
'''Warning:''' The function assumes that self is the current entity trying to snap to the floor.
+
:<code>dist</code> - Unused?
 
+
====Returns:====
=== Return ===
+
:Returns  TRUE if the entity landed on the ground and FALSE if it was still in the air.
Returns <code>TRUE</code> if the entity was placed on valid ground.
+
====Other Details:====
 
+
Note the 256 unit limitation. Typically droptofloor is either to pre-place items and monsters on the ground after a map has loaded but if an entity is  over 256 units from the ground, droptofloor will return false.
== 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;
 
}
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)