getElementDistanceFromCentreOfMassToBaseOfModel | Multi Theft Auto: Wiki Skip to content

getElementDistanceFromCentreOfMassToBaseOfModel

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Required Parameters

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function is used to retrieve the distance between a element's centre of mass to the base of the model. This can be used to calculate the position the element has to be set to, to have it on ground level.

Note

The distance value is only available when the element is streamed in, otherwise 0 is returned. If you create an element at the player's position which is going to be streamed in, call the function in the next frame to obtain the correct value (with setTimer 0ms, for example).

OOP Syntax Help! I don't understand this!

  • Method:element:getDistanceFromCentreOfMassToBaseOfModel(...)
  • Variable: .distanceFromCentreOfMassToBaseOfModel

Syntax

float getElementDistanceFromCentreOfMassToBaseOfModel ( element theElement )
Required Arguments
  • theElement: MISSING_PARAM_DESC

Returns

  • float: value

Returns a float with the distance, or false if the element is invalid.

Code Examples

shared

This example outputs the value for the local player.

local distance = getElementDistanceFromCentreOfMassToBaseOfModel(localPlayer)
outputChatBox(tostring(distance))

See Also

Element Functions