applyForceToEntity
APPLY_FORCE_TO_ENTITY0xC5F68BE9613E2D18The GTA V native APPLY_FORCE_TO_ENTITY of the ENTITY namespace, as LS:MP client scripts call it: the global function applyForceToEntity, in JavaScript and in Lua.
applyForceToEntity(
entity: Entity,
forceFlags: number,
x: number,
y: number,
z: number,
offX: number,
offY: number,
offZ: number,
boneIndex: number,
isDirectionRel: boolean,
ignoreUpVec: boolean,
isForceRel: boolean,
p12: boolean,
p13: boolean
): voidapplyForceToEntity(
entity: Entity,
forceFlags: integer,
x: number,
y: number,
z: number,
offX: number,
offY: number,
offZ: number,
boneIndex: integer,
isDirectionRel: boolean,
ignoreUpVec: boolean,
isForceRel: boolean,
p12: boolean,
p13: boolean
)Usage
applyForceToEntity(
entity, forceFlags, x, y, z, offX, offY, offZ, boneIndex, isDirectionRel, ignoreUpVec,
isForceRel, p12, p13
);applyForceToEntity(
entity, forceFlags, x, y, z, offX, offY, offZ, boneIndex, isDirectionRel, ignoreUpVec,
isForceRel, p12, p13
)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
applyForceToEntity(
entity, forceFlags, pos, off, boneIndex, isDirectionRel, ignoreUpVec, isForceRel, p12, p13
);applyForceToEntity(
entity, forceFlags, pos, off, boneIndex, isDirectionRel, ignoreUpVec, isForceRel, p12, p13
)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
entity | Entity | number | integer |
forceFlags | int | number | integer |
x | float | number | number |
y | float | number | number |
z | float | number | number |
offX | float | number | number |
offY | float | number | number |
offZ | float | number | number |
boneIndex | int | number | integer |
isDirectionRel | BOOL | boolean | boolean |
ignoreUpVec | BOOL | boolean | boolean |
isForceRel | BOOL | boolean | boolean |
p12 | BOOL | boolean | boolean |
p13 | BOOL | boolean | boolean |
Returns
Nothing. In JavaScript the call evaluates to undefined.
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
Documented here:
https://gtaforums.com/topic/885669-precisely-define-object-physics/
https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/
forceFlags:
First bit (lowest): Strong force flag, factor 100
Second bit: Unkown flag
Third bit: Momentum flag=1 (vector (x,y,z) is a momentum, more research needed)
If higher bits are unequal 0 the function doesn't applay any forces at all.
(As integer possible values are 0-7)
0: weak force
1: strong force
2: same as 0 (2nd bit?)
3: same as 1
4: weak momentum
5: strong momentum
6: same as 4
7: same as 5
isLocal: vector defined in local (body-fixed) coordinate frame
isMassRel: if true the force gets multiplied with the objects mass (this is why it was known as highForce) and different objects will have the same acceleration.
Reference
- Namespace
- Entity ENTITY
- In the game
void APPLY_FORCE_TO_ENTITY(Entity entity, int forceFlags, float x, float y, float z, float offX, float offY, float offZ, int boneIndex, BOOL isDirectionRel, BOOL ignoreUpVec, BOOL isForceRel, BOOL p12, BOOL p13)- Hash
0xC5F68BE9613E2D18