ApplyForceToEntity
DocsApplyForceToEntity(entity, forceType, x, y, z, offX, offY, offZ, boneIndex, isDirectionRel, ignoreUpVec, isForceRel, p12, p13)Description
Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity you want to apply a force on |
forceType | int | Refer to `eForceType` |
x | float | Force amount (X) |
y | float | Force amount (Y) |
z | float | Force amount (Z) |
offX | float | Rotation/offset force (X) |
offY | float | Rotation/offset force (Y) |
offZ | float | Rotation/offset force (Z) |
boneIndex | int | (Often 0) Entity bone index |
isDirectionRel | BOOL | (Usually false) Vector defined in local (body-fixed) coordinate frame |
ignoreUpVec | BOOL | (Usually true) |
isForceRel | BOOL | (Usually true) When true, force gets multiplied with the objects mass and different objects will have the same acceleration |
p12 | BOOL | (Usually false) |
p13 | BOOL | (Usually true) |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
voidThis native does not return a value.
Examples
Official
local forceTypes = {
MinForce = 0,
MaxForceRot = 1,
MinForce2 = 2,
MaxForceRot2 = 3,
ForceNoRot = 4,
ForceRotPlusForce = 5
}
local entity = PlayerPedId()
local forceType = forceTypes.MaxForceRot2
-- sends the entity straight up into the sky:
local direction = vector3(0.0, 0.0, 15.0)
local rotation = vector3(0.0, 0.0, 0.0)
local boneIndex = 0
local isDirectionRel = false
local ignoreUpVec = true
local isForceRel = true
local p12 = false
local p13 = true
ApplyForceToEntity(
entity,
forceType,
direction,
rotation,
boneIndex,
isDirectionRel,
ignoreUpVec,
isForceRel,
p12,
p13
)