This is a dedicated corner where we will share useful tips, advice and the know-how using Unreal Engine for all of those who embark on a wonderful journey creating their own special and unique worlds.
For reference, we are using Unreal Engine 4.24.
Eventually you get to a stage where you realise that you need to apply Physics to your Animation Blend, this becomes quite apparent for larger and more complex characters interacting within a rich enviroment.
This article assumes you are familiar with Physics Assets, which you have to create in order to enable physics simulation on you model, configure constraints and physical animation blend. And your character does not get torn apart or flies into space the moment you simulate physics :). For the core setup please refer to Unreal Documentation.
The problem we will address is as follows: Your NPC (Blueprint: Character Class) stops moving the moment you set Simulate Physics to true on the underlying mesh.
There are several threads out there where it is suggested that AI Controller cannot navigate an asset with Physical Simulation turned on and that the work-around is quite complex and requires writing C++ code due to "[inherited] Character Movement Component reliqushing control to Physics Engine".
This is simply not quite true, and below are the steps how to get your Physics Animation Blended character moving under AI ..again.
1. Open up PA Editor.
2. Create a new shape right under the Root node (does not matter what type) and let's call it PK (Parent Kinematic).
3. Set PK's Physics Type from Default to Kinematic.
4. Navigate to the Pelvis bone Constraint node (Pelvis: Root Constraint).
5. Remove Linear Limits by setting X, Y, Z Motion from Locked to Free.
Done! Your character will resume its motion as driven by AI!
Please note: your set up, of course, will depend on the bone hierarchy, but we hope the priciple is clear.
Another essential feature which is not directly documented, but can be deduced, enables you to add text or animated text to your "cut-scene" sequences, this may include fading subtitles or scrolling credits (you can find examples in our video clips in Media section).
A commonly asked question is "Can I add text/text widget to a Sequencer Viewport?". The short answer is "Yes, you can". And we already added our two-cents to one of the Unreal Engine Forum's threads, but here is a step-by-step how-to.
This article assumes that you already have a Sequence you want to add text to and that you have attained a certain level of compentency with UMG UI.
Without further ado, let's get started...
1. Create a Widget Blueprint, we called it SubtitleBP.
2. Add a TextBox, we called it TextBox, and set Is Variable to true. This will allow us reference the widget within a BP.
3. Optionally you can set up any kind of animation for the TextBox widget, for example Opacity, Color, Transform etc. or any combination of.
4. In the BP's Graph define a function SetText which takes a single String input, to update textual content of the TextBox (triggering animation if any).
Next, we need to generate events from our Sequence that would call BP's SetText to update the content of the TextBox...
5. Open your main Sequence in Sequencer and add a new Event Track.
6. Add a new Track Event calling it SequenceTextEvent and specifying a Payload string to whatever text it needs to be.
7. And finally, double-left click on the newly defined event to open Sequence Director and wire event handling as follows:
You are all set! You have a reusable Subtitles Blueprint which you may further parametrise and customise to fit your needs, not forgetting the clean-up logic.
The text specified via Payload (played together with its animation if configured) will be pushed through each time an instance of the event is emitted.
Unreal has a very powerful and enabling feature - Animation Retargeting, which alows you to reuse animation across skeletal rigs. This tutorial will explain exactly what needs to be done and why.
Broadly speaking there are three scenarios when retargeting can work:
- Skeletons are the same
- Skeletons are similar (eg. both are UE4 humanoid rigs, but the modified has different proportions to the original, bones moved)
- Skeletons are different, but there is still reasonable similarity in general shape and hierachy (e.g. two humanoid rigs but one is UE4 and the other is Mixamo)
Only when the two models are rigged against the same skeleton, the minimal effort is requried - just retarget the animation.
The moment you adjust any bone size (typically moving head/tail of a bone), for the copy of the original, the skeleton IS NO LONGER THE SAME as far as the Engine is concerned. And you need to create "translation from a reference" so to speak, aka Rig+Pose and then tell the engine which translation you want to apply for your bones Skeleton, Animation etc. And it might be just as well you are working against a skeleton generated by another system (third scenario). However you are still advised to work against the skeletons you have majority of animations for, as you it will save you addiontal steps such as bone remapping and figuring out what to do with the lack/excess of bones.
So the latter two scenarious both require skeletal retargeting, and that's key.
In theory the Engine could autodetect the second scenario and autogenerate the rig and set the modified pose reference, but it can't default the source of retargeting per bone as it will vary per usecase.
Fortunately, skeletal retargeting is a very straight forward process. As per documentation :
1. Create a Rig from the original skeleton asset.
2. Assign the rig to both new and adjusted skeleton via Retarget Manager. Now when you try to retarget animations they modified skeleton will be listed even with "Show Only Compatible Skeletons" check box set.
3. Set current pose for your modified skeleton (Retarget Manager->Modify Pose->Use CurrentPose). So now the Engine knows how to translate between the original bones and the target.
4. Tell the Engine what to use as the source for the translation ("Bone Translation Retargeting") during amination by enabling "Retargeting Options" in Skeleton Tree (Skeleton Tree->Options->Show Retargeting Options). The guides for which bones should use what are in the documentation under "Setting Up Retargeting".
5. Finally, retarget your animation/BP asset via Retarget Anim Asset->Duplicate Anim Asset And Retarget.
After this you should have perfectly retargeted animations, without any distortions!