|
Drops the object down till it hits the floor\ground
If the object is below the ground the function will actually move it up
and put it on top of the above ground
Return Value.
Returns a handle to the polygon bellow.
Parameters:
object_handle: the object to be dropped.
fall_through_dynamic_objects: Could be set to YES or NO.
Notice the following code sample:
Lets assume that we have a terrain world and we want to move our character forward
STATE_object_move(my_object, OBJECT_SPACE, -10, 0, 0); Move the object 10 units forward. If we are in front
of a mountain slope, it could get us into the mountain.
STATE_object_move(my_object, WORLD_SPACE, 0, 0, 10000000); Move the object up in the air so if we have penetrated the mountain
with our previous move then now we are above the mountain
STATE_object_drop_down(my_object, NO); Drop the player nicely on the ground
The code above will work very nicely till there is a helicopter or a bird that
flys above our player. If so, our player will drop down on a the helicopter instead
of on the ground. In this case of this game we better call with fall_through_dynamic_objects==YES
match_ground_angle: YES or NO. If YES is given then the object will turned so it matches the ground surface
for example if we drop a car on a road going uphill then giving YES will insure that
the car will be positioned according to the road incline and that its four wheel will contact the road
Note that if we drop a tree on a mountain side that we should give NO since trees grow upwards ...
Example A
DWORD floor_polygon=STATE_object_drop_down(my_object);
if(floor_polygon==NULL)
error_message("The object has nothing below !!!);
Example B
an alternative to STATE_object_drop_down()
double min_height, max_height;
DWORD poly=STATE_object_get_bounding_box_height_above_ground(my_object, NO, &min_height, &max_height);
if(poly!=NULL)
STATE_object_move(my_object, WORLD_SPACE, 0,0, -max_height);
Note that STATE_object_drop_down() would calculate the height
according to the center of the object and not according the the max_height
as shown here
Remarks:
See also STATE_object_drop_down_fast(), STATE_object_get_bounding_box_height_above_ground()
|