Skip to content

Conversation

@FileEX
Copy link
Member

@FileEX FileEX commented Nov 18, 2025

Closes #1977, #362
Merge after #4052

This PR adds support for custom object animations. Animations can be applied both to a model ID and to a specific entity (supported for objects and buildings).

https://www.youtube.com/watch?v=wn0R0C1vLp0

Syntax

bool engineSetModelAnimation(int model, ifp animFile, string animName, [ int flags = 0x2 ] )
bool engineSetModelAnimation(int model, bool disableAnim)
nil engineRestoreModelAnimation(int model)

bool setElementAnimation(element theElement, ifp animFile, string animName, [ int flags = 0x2 ] )
bool setElementAnimation(element theElement, bool disableAnim)
bool setElementAnimationSpeed(element theElement, float speed)

Code from video

local ifp = engineLoadIFP("obj_anim.ifp", "obj_anim")

local txd = engineLoadTXD("test.txd");
local dff = engineLoadDFF("test.dff");

engineConvertModelToType(1337, "clump")

engineImportTXD(txd, 1337)
engineReplaceModel(dff, 1337)

local obj = createBuilding(3425, 2485.03027, -1676.34106, 12.33802)
setElementAnimationSpeed(obj, 10)

local objw2 = createObject(3425, 2478.41260, -1663.71875, 12.33372);

local obj2 = createObject(1337, 2492.38232, -1674.29016, 12.33595)
setElementAnimation(obj2, ifp, 'Spin')
setElementAnimationSpeed(obj2, 0.2)

local obj3 = createObject(1337, 2491.65942, -1667.57007, 12.34375)
setElementAnimation(obj3, ifp, 'Left_Right')

engineSetModelAnimation(13562, false)
local obj4 = createObject(13562, 2472.57715, -1673.12170, 13.33592)

I’m not sure if more complex animations work, because in #1977 it was mentioned:

But before we can play object anims, the object must have skinned data like peds in the dff model
engineReplaceModel crashes when trying to load skin data for object models

Unfortunately, I don’t have a more advanced model or animations to test this case, so there is no guarantee that it works. If someone encounters this issue in the future and provides me with a model for testing, I'll fix the crash.

Thanks to @1Selective for the model and animations used for testing.

@MegadreamsBE
Copy link
Member

HOLY SHIT. You are a legend

@Fernando-A-Rocha
Copy link
Contributor

Fernando-A-Rocha commented Nov 18, 2025

HOLY SHIT. You are a legend

Stole my words

You shall test this with cutscenes my friend 😁

@Fernando-A-Rocha
Copy link
Contributor

Can we finally have parachute object animations like singleplayer???

@matheustkn
Copy link
Contributor

Amazing

@THEGizmoOfficial
Copy link

THEGizmoOfficial commented Nov 18, 2025

Finally!! what's still missing is fixing the UV animation XD

@FileEX
Copy link
Member Author

FileEX commented Nov 18, 2025

Finally!! what's still missing is fixing the UV animation XD

If you create an issue, clearly describe what you mean, and attach example files for testing, I’ll take care of it.

@vitor3g
Copy link

vitor3g commented Nov 18, 2025

🙏🏻

@W3lac3
Copy link
Contributor

W3lac3 commented Nov 19, 2025

Congrats on the work! This feature has a lot to add to the game. One thing that would be great to have along with this new feature is the ability to use the bone-manipulation functions, such as setElementBoneRotation, setElementBonePosition, setElementBoneQuaternion, setElementBoneMatrix, etc.

@FileEX
Copy link
Member Author

FileEX commented Nov 19, 2025

Congrats on the work! This feature has a lot to add to the game. One thing that would be great to have along with this new feature is the ability to use the bone-manipulation functions, such as setElementBoneRotation, setElementBonePosition, setElementBoneQuaternion, setElementBoneMatrix, etc.

My next plan is to create a function for modifying object frames, something like vehicle components - setElementFramePosition/Rotation/Scale

@MegadreamsBE
Copy link
Member

I have tested this thoroughly yesterday. For conventional object animations, it works perfectly. It does struggle with some animations found in cutscenes, mainly whenever the root bone is set to anything but "root". Some have it capitalized as "Root", or named different altogether. Cutscene peds also work for the most part! You can load them in as objects and apply the IPL, basically what the game does as well. Facial bones aren't working at the moment unfortunately, but all the other limbs are!

@nekjutsu
Copy link

Amazing

@FileEX
Copy link
Member Author

FileEX commented Nov 21, 2025

I have tested this thoroughly yesterday. For conventional object animations, it works perfectly. It does struggle with some animations found in cutscenes, mainly whenever the root bone is set to anything but "root". Some have it capitalized as "Root", or named different altogether. Cutscene peds also work for the most part! You can load them in as objects and apply the IPL, basically what the game does as well. Facial bones aren't working at the moment unfortunately, but all the other limbs are!

Facial bones fixed in #4565

@FileEX FileEX added the enhancement New feature or request label Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object animations

8 participants