Skip to content

Fix custom partial animations leaving peds rigid - #5101

Merged
FileEX merged 2 commits into
multitheftauto:masterfrom
TheCrazy17:fix/partial-animation-support
Jul 30, 2026
Merged

Fix custom partial animations leaving peds rigid#5101
FileEX merged 2 commits into
multitheftauto:masterfrom
TheCrazy17:fix/partial-animation-support

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

Replacing a partial animation, like any of the weapon fire ones, with an animation loaded from a custom IFP left the ped rigid. It could still be walked around, but the legs and torso stopped animating and it stayed locked facing one direction.

Loading an IFP pads every animation out to all 32 bones and fills the ones the animation does not define with a fixed pose. A full body animation needs that padding, but a partial animation is only meant to drive part of the skeleton and leave the rest to whatever movement animation is playing, so the padding ended up driving the root, pelvis and legs as well.

The replacement is now trimmed back to the bones the original animation drives, read from its static association, so the padding can no longer reach bones the original never touched. This only runs for partial animations, so full body replacements keep taking exactly the same path as before.

Before: https://www.youtube.com/watch?v=gqyxviWVcJE

After:

MTA_.San.Andreas.DEBUG.mp4

Motivation

Fixes #2733 and #3055.

Custom weapon animations have been unusable for a long time.

Test plan

partialanimtest.zip

Tested with a small resource that loads a custom shotgun.ifp and binds two keys, one calling engineReplaceAnimation on "shotgun" / "shotgun_fire" and the other calling engineRestoreAnimation to go back to the stock one.

Before the change, once the animation was replaced, aiming and firing the shotgun locked the ped facing a single direction with the legs and torso frozen, so it slid around without any walking animation.

After the change, the custom fire animation plays on the upper body while the ped keeps walking, turning and animating normally, and restoring brings the stock animation back.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Replacing a partial animation like a weapon fire with one from a custom IFP
left the ped rigid; it could still walk around, but its legs and torso stopped
animating.

Loading an IFP pads every animation out to all 32 bones, filling the ones it
does not define with a fixed pose. A partial animation is only meant to drive
part of the skeleton, so that padding took over the root, pelvis and legs as
well. The replacement is now trimmed back to the bones the original animates,
read from its static association.
@RughCuttle

Copy link
Copy Markdown

Tested this and it worked. I tested with all the custom animations he provided in the test script. I've even test with fighta_block and no problems.

Comment thread Client/game_sa/CAnimBlendAssociationSA.h Outdated
@FileEX FileEX added the bugfix Solution to a bug of any kind label Jul 30, 2026
@FileEX

FileEX commented Jul 30, 2026

Copy link
Copy Markdown
Member

I think it would be good to have this in the upcoming 1.7 release. It looks good to me, and I trust that RughCuttle has tested it.

@FileEX
FileEX merged commit b785d45 into multitheftauto:master Jul 30, 2026
10 checks passed
@FileEX FileEX added this to the 1.7 (Current) milestone Jul 30, 2026
@TheCrazy17
TheCrazy17 deleted the fix/partial-animation-support branch July 30, 2026 12:48
@PlatinMTA

Copy link
Copy Markdown
Contributor

goated PR, thank you so much dude

TheCrazy17 added a commit to TheCrazy17/mtasa-blue that referenced this pull request Jul 31, 2026
Dropped noexcept from two functions that touch raw game memory, per
FileEx's feedback on multitheftauto#5101. Removed an unused GetTrainTrack accessor,
a stray forward declaration, and an old comment from before this
branch existed.
FileEX pushed a commit that referenced this pull request Aug 2, 2026
)

#### Summary

Fixes custom partial animations played straight from a custom IFP bank
(via `engineLoadIFP` + `setPedAnimation`) leaving the ped rigid, the
same padding problem #5101 fixed for `engineReplaceAnimation`.

`CClientIFP` pads every loaded animation out to 32 bones regardless of
what the source IFP actually defines. #5101 trimmed that padding by
comparing against the built-in animation being replaced, but an
animation played directly from a custom bank has no built-in original to
compare against, so the fix never applied there and the padding kept
driving the root, pelvis and legs.

`CClientIFP` now records which bones an animation actually defines while
parsing it. `CAnimBlendAssociation` gains `RestrictToBones(mask)`, a
sibling of `RestrictToBonesOf` driven by that record instead of a
built-in original; `CClientPed` applies it once the animation is
actually playing.

#### Motivation

Continuation of #5101. That fix only covered animations replacing a
built-in one; partial animations loaded into their own custom bank and
played directly still went rigid. Fixes #5121.

#### Test plan

Loaded a custom IFP with a partial animation (upper body only, e.g.
`crry_prtial`) into a custom bank via `engineLoadIFP`, played it with
`setPedAnimation` on a ped. Before the fix the ped froze in place;
after, the custom animation plays on the upper body while walking,
turning and leg movement keep working normally. Also re-tested #5101's
original `engineReplaceAnimation` scenario to confirm that path is
untouched.

Test script, thanks to @RughCuttle

[partialtest.zip](https://github.com/user-attachments/files/30626244/partialtest.zip)


#### Checklist

* [x] Your code should follow the [coding
guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines).
* [x] Smaller pull requests are easier to review. If your pull request
is beefy, your pull request should be reviewable commit-by-commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot replace weapon animations

4 participants