-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
document 2 force natives #1203
Open
coalaura
wants to merge
5
commits into
citizenfx:master
Choose a base branch
from
coalaura:force
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
−63
Open
document 2 force natives #1203
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,76 +5,62 @@ ns: ENTITY | |||||||||
|
||||||||||
```c | ||||||||||
// 0xC5F68BE9613E2D18 0xC1C0855A | ||||||||||
void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int boneIndex, BOOL isDirectionRel, BOOL ignoreUpVec, BOOL isForceRel, BOOL p12, BOOL p13); | ||||||||||
void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int nComponent, BOOL bLocalForce, BOOL bLocalOffset, BOOL bScaleByMass, BOOL bPlayAudio, BOOL bScaleByTimeWarp); | ||||||||||
``` | ||||||||||
|
||||||||||
Applies a force to the specified entity. | ||||||||||
Apply a force to an entity. More research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). | ||||||||||
|
||||||||||
```c | ||||||||||
enum eForceType | ||||||||||
{ | ||||||||||
MinForce = 0, | ||||||||||
MaxForceRot = 1, | ||||||||||
MinForce2 = 2, | ||||||||||
MaxForceRot2 = 3, | ||||||||||
ForceNoRot = 4, | ||||||||||
ForceRotPlusForce = 5 | ||||||||||
```cpp | ||||||||||
enum eCommandApplyForceTypes { | ||||||||||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
APPLY_TYPE_FORCE = 0, | ||||||||||
APPLY_TYPE_IMPULSE = 1, | ||||||||||
APPLY_TYPE_EXTERNAL_FORCE = 2, | ||||||||||
APPLY_TYPE_EXTERNAL_IMPULSE = 3, | ||||||||||
APPLY_TYPE_TORQUE = 4, | ||||||||||
APPLY_TYPE_ANGULAR_IMPULSE = 5 | ||||||||||
} | ||||||||||
``` | ||||||||||
|
||||||||||
Research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). | ||||||||||
coalaura marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
|
||||||||||
## Parameters | ||||||||||
* **entity**: The entity you want to apply a force on | ||||||||||
* **forceType**: Refer to `eForceType` | ||||||||||
* **x**: Force amount (X) | ||||||||||
* **y**: Force amount (Y) | ||||||||||
* **z**: Force amount (Z) | ||||||||||
* **offX**: Rotation/offset force (X) | ||||||||||
* **offY**: Rotation/offset force (Y) | ||||||||||
* **offZ**: Rotation/offset force (Z) | ||||||||||
* **boneIndex**: (Often 0) Entity bone index | ||||||||||
* **isDirectionRel**: (Usually false) Vector defined in local (body-fixed) coordinate frame | ||||||||||
* **ignoreUpVec**: (Usually true) | ||||||||||
* **isForceRel**: (Usually true) When true, force gets multiplied with the objects mass and different objects will have the same acceleration | ||||||||||
* **p12**: (Usually false) | ||||||||||
* **p13**: (Usually true) | ||||||||||
|
||||||||||
* **entity**: The entity handle | ||||||||||
* **forceType**: The force type | ||||||||||
* **x**: The x component of the force to apply | ||||||||||
* **y**: The y component of the force to apply | ||||||||||
* **z**: The z component of the force to apply | ||||||||||
* **offX**: Offset from center of entity (X) | ||||||||||
* **offY**: Offset from center of entity (Y) | ||||||||||
* **offZ**: Offset from center of entity (Z) | ||||||||||
* **nComponent**: Component of the entity to apply the force too. Only matters for breakable or articulated (ragdoll) physics. 0 means the root or parent component | ||||||||||
* **bLocalForce**: Specifies whether the force vector passed in is in local or world coordinates. `true` means the force will get automatically transformed into world space before being applied | ||||||||||
* **bLocalOffset**: Specifies whether the offset passed in is in local or world coordinates | ||||||||||
* **bScaleByMass**: Specifies whether to scale the force by mass | ||||||||||
* **bPlayAudio**: Specifies whether to play audio events related to the force being applied. The audio will depend on the entity type. Currently vehicles are the only entity types supported, and will play a suspension squeal depending on the magnitude of the force | ||||||||||
* **bScaleByTimeWarp**: Specifies whether to scale the force by time warp. Default is `true` | ||||||||||
coalaura marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
## Examples | ||||||||||
```lua | ||||||||||
local forceTypes = { | ||||||||||
MinForce = 0, | ||||||||||
MaxForceRot = 1, | ||||||||||
MinForce2 = 2, | ||||||||||
MaxForceRot2 = 3, | ||||||||||
ForceNoRot = 4, | ||||||||||
ForceRotPlusForce = 5 | ||||||||||
} | ||||||||||
|
||||||||||
local entity = PlayerPedId() | ||||||||||
local forceType = forceTypes.MaxForceRot2 | ||||||||||
local forceType = 2 | ||||||||||
-- 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 | ||||||||||
local offset = vector3(0.0, 0.0, 0.0) | ||||||||||
local component = 0 | ||||||||||
local localForce = false | ||||||||||
local localOffset = true | ||||||||||
local scaleByMass = true | ||||||||||
local playAudio = false | ||||||||||
local scaleByTimeWarp = true | ||||||||||
|
||||||||||
ApplyForceToEntity( | ||||||||||
entity, | ||||||||||
forceType, | ||||||||||
direction, | ||||||||||
rotation, | ||||||||||
offset, | ||||||||||
boneIndex, | ||||||||||
isDirectionRel, | ||||||||||
ignoreUpVec, | ||||||||||
isForceRel, | ||||||||||
p12, | ||||||||||
p13 | ||||||||||
localForce, | ||||||||||
localOffset, | ||||||||||
scaleByMass, | ||||||||||
playAudio, | ||||||||||
scaleByTimeWarp | ||||||||||
) | ||||||||||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be enough documentation for this link to no longer be needed