UE5 ControlRig issue
On YouTube, people talk about features, how-to, step-by-step... but... it boggles me why no one talks about the issues.
Today, I'm going to write one about our beloved ControlRig.
3 facts.
- Inside your ControlRig code, you won't be able to obtain/read this FInterped Alpha value.
- ControlRig stops, ticks no more, onces the alpha reaches 0.
- There's no... OnStartTicking but only a constructor for you to initialize your values.
What's the issue then?
Inside the ControlRig code, instead of a "instant snap", normally, you'd want to "interp" LookAt location from [current looking direction], which is decided by the current animation, to [where you want the character to look], to achieve a natural looking result..
So, we need 3 variables. CurrentLookAt (from animation), TargetLookAt (look at target) and InterpLookAt (the value for interpolation).
Say, a character with an idle animation is spawned at location(0,0,0), currently looking at (20, 0, 0).
Now you want to make it look at location(15, 15, 0).
You need to 1st, initialize InterpLookAt. So,
if (not initialized) { InterpLookAt = CurrentLookAt; } |
then during runtime, you
InterpLookAt = Interp(InterpLookAt, TargetLookAt, 2 seconds); |
to get a smooth head turning result.
Character is now looking at (15,15,0). FInterped Alpha is now at 1.
Then you ask the character to look at (15, -15, 0), you get a smooth head turning from (15, 15, 0) to (15, -15, 0). So far so good.
Then you tell character to stop looking at anything, back to its animation default. After 2 seconds, the InterpLookAt is now (20, 0, 0).
And... maybe, you'd want to set FInterped Alpha back to 0? Cus you are not looing at anything no more.
So you did. FInterped Alpha is now at 0. No more ticking.
Then you move the character to location(40, 0, 0). Character is now looking at location(60,0,0).
Now, what happens if you ask the character to look at location(55,15,0).
- head turns from location(60,0,0) to location(50, 15, 0)?
- head turns from location(20,0,0) to location(50, 15, 0)?
The answer is 2. Instead of you curreent look location, you will start from the LAST look at location.
Solution
- I've asked Epic to give us a way to obtain this FInterped Alpha value. They are considering it.
- Meantime, this is my ugly workaround.
- There's no interp node insude the AnimationBluePring right now. I had to create one using some wacky hack around.
- Then I passed that "Interped Alpha", to both the ControlRig and my Code, so I can create a pseudo OnStartTicking, so I get to RE-initialize my InterpLookAt to CurrentLookAt.
Comments
Post a Comment