ALS-Refactored icon indicating copy to clipboard operation
ALS-Refactored copied to clipboard

Integrate Physical Animation Component

Open SAM-tak opened this issue 1 year ago • 8 comments

Physical Animation

BeforeAfter

When trying to integrate the PhysicalAnimationComponent, I initially tried to define it in a derived class of AlsCharacter to avoid making changes to AlsCharacter. However, this didn’t work well with the ragdoll processing, so I decided to make changes to AlsCharacter itself.

In addition, I made several improvements to the ragdoll processing. I removed all the motor drive settings for the constraints that were being applied to adjust the pose during ragdolling, and unified them under physical animation.

Also, I added a Freeze feature that stops the physical simulation after the movement of the physical body falls below a certain value or after a certain period of time has passed.

Ragdoll

AB_Als_Ragdolling

During ragdolling, not only the previous Flail animation but also the Lying down pose after landing is used as the target to drive the physical animation. This makes it easier to converge to a posture that leads to the GetUp action.

In the future, it would be beneficial to make AB_Als_Grounded capable of handling a new state, Lying, and set the physical animation target during ragdolling to the Input Pose itself. This would eliminate the need for any Sequence Player within AB_Als_Ragdolling.

The naming convention for Physical Animation Profile names

If a Physical Animation Profile with a name corresponding to ALS’s LocomotionMode, LocomotionAction, Stance, Gait, and OverlayMode exists, it will be applied. Only the physical bodies included in the Physical Animation Profile will be subject to simulation, and all others will be set to kinematic.

Names should either match exactly with LocomotionMode or LocomotionAction, Stance, Gait, OverlayMode (such as Grounded or Ragdolling), or they should be a concatenation of LocomotionMode or LocomotionAction, Stance, Gait, OverlayMode in that order, separated by :.

For example, if you want a profile to be applied only when LocomotionMode=Grounded, Stance=Standing, and Gait=Running, you would name it Grounded:Standing:Running.

If there is no profile with a name that matches the current state, and there is a profile named “Default”, then the “Default” profile will be selected. If a name starts with +, it means that the profile is to be added and applied to any other matching profiles.

If a name starts with *, it can overwrite only the physical animation parameters without affecting the on/off state of the physical simulation, after applying other matching profiles.

Example of physical aniImation profile

The *Injured profile, when the overlay mode is Injured, changes only the physical animation parameters without changing the range of physical simulation, after the Default or Mantle profile is applied.

During ragdolling, only profiles named Ragdolling or those containing Ragdolling in their names, such as Ragdolling:Injured, will be applied.

If you only create the Ragdolling profile and do not create a Default profile, the effects of the physical animation will only be applied during ragdolling.

Animation Curve

Added new curves below:

  • PALockArmLeft
  • PALockArmRight
  • PALockLegLeft
  • PALockLegRight
  • PALockHandLeft
  • PALockHandRight
  • PALockFootLeft
  • PALockFootRight

By setting a value greater than 0 to these animation curves in animation sequence or animation montage, you can temporarily disable the corresponding physical animation without switching profiles.

For example, during Mantling, these curves are set to disable the physical animation of the corresponding parts temporarily, so as not to interfere with the action of lifting the leg high.

SAM-tak avatar Nov 12 '23 11:11 SAM-tak

@Sixze I think I’ve found a solution to Ragdolling problem at low FPS.

Just turn on 'Substepping' in Physics section of Project Settings.

image

It seems like there’s no need to change the code.

SAM-tak avatar Nov 14 '23 03:11 SAM-tak

this is based

dG9hc3Q avatar Nov 14 '23 08:11 dG9hc3Q

Good job. I'll definitely take a closer look at this, but I'm busy right now so it won't be anytime soon.

Sixze avatar Nov 17 '23 23:11 Sixze

I fixed the issue where the posture when start ragdolling during strafing was unnatural because it did not match the direction of movement.

This is likely the last commit I will add to this PR, and I don’t expect to add any more commits after this.

SAM-tak avatar Nov 20 '23 03:11 SAM-tak

Could this be integrated via a derived class such as ALSXT without needing to modify the source or ALS assets?

colorindarkness avatar Jan 27 '24 15:01 colorindarkness

Could this be integrated via a derived class such as ALSXT without needing to modify the source or ALS assets?

The original ragdolling process collides with PhysicalAnimation, and I think that ragdolling is better impremented with PhysicalAnimation than the conventional method of setting drive to constraints. It’s hard work to keep the original source and assets unchanged, so I don’t have the motivation to do that.

SAM-tak avatar Feb 02 '24 12:02 SAM-tak

Please close this PR if you don’t like it. I will continue to develop with ALSRefactored customized for myself in the forked repository, so I don’t have any particular reason to want you to merge it.

SAM-tak avatar Feb 03 '24 10:02 SAM-tak

Please close this PR if you don’t like it. I will continue to develop with ALSRefactored customized for myself in the forked repository, so I don’t have any particular reason to want you to merge it.

I apologize for not looking at this PR, I'm still quite busy. I don't want to make predictions, but I think it will happen only after the release of UE 5.4.

Sixze avatar Feb 03 '24 18:02 Sixze

I can't open modified montages, this error occurs:

Error        LogWindows                appError called: Assertion failed: bRequiresModelPopulation || DataModel != nullptr || DataModelInterface != nullptr [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Animation\AnimSequenceBase.cpp] [Line: 129] 
Error        LogWindows                Invalid Animation Sequence base state, no data model found past upgrade object version. AnimSequenceBase:/ALS/ALS/Animations/Actions/Mantle/A_Als_Mantle_High.A_Als_Mantle_High

Maybe you saved them under a different version of Unreal Engine?

Sixze avatar Mar 25 '24 16:03 Sixze

I tested on UE5.3.2(not source build). I haven't seen this assertion error in my environment. I'll check it again.

SAM-tak avatar Mar 26 '24 21:03 SAM-tak

I’m sorry, it seems I accidentally mixed in some unnecessary changes. It was strange that there were changes to A_Als_Mantle_High.asset. I have force-pushed a version with the unnecessary changes removed.

SAM-tak avatar Mar 28 '24 03:03 SAM-tak

The editor still crashes due to the A_Als_LyingDown_Back_Pose and A_Als_LyingDown_Front_Pose animations.

Sixze avatar Mar 28 '24 16:03 Sixze

A_Als_LyingDown_Back_Pose and A_Als_LyingDown_Front_Pose are newly added data, so they are necessary. A_Als_LyingDown_Back_Pose is created from the first frame of A_ALs_GetUp_Back, and A_Als_LyingDown_Front_Pose is created from the first frame of A_ALs_GetUp_Front. I don’t get any asserts in my environment. Do you think asserts will occur in someone else’s environment?

SAM-tak avatar Mar 29 '24 09:03 SAM-tak

@Sixze Could you check if the Animation Data plugin is not turned off? It is a plugin that is on by default from version 5.2 onwards, but it seems that the ascension error mentioned above occurs when it is off. image

SAM-tak avatar Mar 31 '24 03:03 SAM-tak

Could you check if the Animation Data plugin is not turned off? It is a plugin that is on by default from version 5.2 onwards, but it seems that the ascension error mentioned above occurs when it is off.

Yes, it looks like this plugin is the cause of crashes. I had it disabled. Could you please reupload modified animations?

Sixze avatar Mar 31 '24 13:03 Sixze

Could you check if the Animation Data plugin is not turned off? It is a plugin that is on by default from version 5.2 onwards, but it seems that the ascension error mentioned above occurs when it is off.

Yes, it looks like this plugin is the cause of crashes. I had it disabled. Could you please reupload modified animations?

In my case, turning it off causes a crash. This is likely a bug that has been present since UE5.2.

https://forums.unrealengine.com/t/ue-5-2s-new-animation-compression-changes-introducing-ddc-invalidation-each-editor-startup/790180/2

If you delete all intermediate files using commands like:

FOR /d /r %%d IN ("Binaries","Build","Intermediate","Saved","DerivedDataCache") DO @IF EXIST "%%d" rd /s /q "%%d"
del *.sln

and then start up, perhaps you can launch with the Animation Data plugin still turned on?

SAM-tak avatar Mar 31 '24 23:03 SAM-tak

Could you check if the Animation Data plugin is not turned off? It is a plugin that is on by default from version 5.2 onwards, but it seems that the ascension error mentioned above occurs when it is off.

Yes, it looks like this plugin is the cause of crashes. I had it disabled. Could you please reupload modified animations?

In my case, turning it off causes a crash. This is likely a bug that has been present since UE5.2.

https://forums.unrealengine.com/t/ue-5-2s-new-animation-compression-changes-introducing-ddc-invalidation-each-editor-startup/790180/2

If you delete all intermediate files using commands like:

FOR /d /r %%d IN ("Binaries","Build","Intermediate","Saved","DerivedDataCache") DO @IF EXIST "%%d" rd /s /q "%%d"
del *.sln

and then start up, perhaps you can launch with the Animation Data plugin still turned on?

Ah, sorry, it seems that deleting the cache and intermediate files and rebuilding does not resolve the issue.

SAM-tak avatar Apr 01 '24 01:04 SAM-tak

In my case, turning it off causes a crash. This is likely a bug that has been present since UE5.2.

I meant that I had that plugin disabled, but after enabling it, the engine no longer crashes, so everything is fine.

Sixze avatar Apr 01 '24 08:04 Sixze

Hello, I've reviewed your PR, you did a good job, but I'm not ready to merge it into the plugin.

While physical animations are an interesting topic, they introduce too many different nuances, for example, the character can no longer hold items like a rifle correctly with two hands, hands often get stuck in the world geometry, legs for some reason can stretch in an unnatural way when the character is standing on stairs, and so on.

I'm not sure these problems can be easily fixed, and I'm not ready to spend a lot of time on them.

Also in UE 5.1, Epic introduced the Physics Control Component, which seems to replace the Physical Animation Component, so I think you should take a look at it.

By the way, I like the idea that when the character is lying on the ground, it tries to adopt some specific pose. If it will be possible, I will try to implement this feature separately from this PR and without using Physical Animation Component.

Sixze avatar Apr 04 '24 17:04 Sixze

the character can no longer hold items like a rifle correctly with two hands, hands often get stuck in the world geometry, legs for some reason can stretch in an unnatural way when the character is standing on stairs

I apologize for the confusion. The changes to A_Als_Mantle_High.asset and others that were previously retracted due to the assert failure are not unnecessary but essential. I had forgotten about them myself.

The above phenomenon was largely resolved by controlling the application of PhysicsAnimation with the PALock* animation curves. I have reconfigured it and pushed the changes. Could you please try it out?

Also in UE 5.1, Epic introduced the Physics Control Component, which seems to replace the Physical Animation Component

Ah, the Physics Control Component, I wasn’t aware of that. I was wondering how to include accessories like guns in the simulation, but this seems like it could be the solution.

SAM-tak avatar Apr 06 '24 06:04 SAM-tak

I've looked at your changes, but there are still a lot of issues that I think can only be fixed by limiting the cases where physical animations will have effect.

Most likely you will have to disable collision of physical bodies with other physical bodies inside the physical asset and disable collision with static world geometry, which I think would make physical animations meaningless.

As I said before I'm not ready to spend time on fixing them: I think it will take a lot of time and the final result probably won't be worth it.

Sixze avatar Apr 06 '24 13:04 Sixze

Removing the Default profile can completely eliminate the impact, but… Well, I’m tired too, so I’ll withdraw this PR

SAM-tak avatar Apr 07 '24 03:04 SAM-tak