How to get rotation value to rotate bone from one rotation to another?

Hello,

I have 2 rotators:

  • Rotator A (start position): X=-95 Y=-14 Z=58
  • Rotator B (target position): X=-123 Y=10 Z=30
    CombineRotators is used to rotate the bone from start to target positions.
    But I can’t get the correct Rotation Value that is required in “B” of CombineRotators.
    So I can’t rotate my bone to the target position (Rotator B).

Goal:
Calculate Rotator Value that goes into “B” of CombineRotators.

To check your solution:

  • set Rotator A to X=-95 Y=-14 Z=58 (or make rotator) and plug it into “A” of CombineRotators.
  • calculate Rotation Value and plug it into “B” of CombineRotators.
  • check if return value equals Rotator B (X=-95 Y=-14 Z=58 or P=-14 Y=58 R=-95 if printing string).

The purpose of it a bit wired… I’m trying to avoid cloth simulation with “corrective bones”.
So I have a number extra bones to be controlled by animation blueprint (not included in animations).
I want my bone to copy rotation from one bone using Copy Bone first. And then add rotation of another bone with Transform (Modify) Bone but using Add to Existing as Rotation Mode (it uses CombineRotators function).

Using Replace Existing as Rotation Mode gets the bone in the correct position, but there is a delay caused by processing information from character blueprint (and it causes clipping). Rotator B calculation is based on leg position in relation to another, so different values are used if the leg is in front on behind the other one.

I’ve been stuck on this for couple days now and I hope to find someone willing to help me out.
Thank you.

Test Rotation Value

The problem is probably the rotation value variable?
Is it ever getting updated? Who’s saving the correct value of it?
And who’s reading it back out?

Also, describe in a poor 90 year old man 6 word sentence your end goal.

Overly simplifying the problem might lead you to think on your own of a better solution, and us to give you a clearer path way to get things done.

As far as combine rotators goes, it converts to fQuat before adding the 2, then converts back to rotator.

So if you have a set start, and a set end, that are less than 360 on all axis apart, you may also be able to just Add the 2 rotators togeter.
Generally that’s a horrible idea - in your example case, this may turn out as a better way to get the final value…

Also, if the problem is just that when you combine the 2 the end result is yanked into place.
A) that’s normal.
B) you can correct the bone position over time with a lerp or a timeline.

Actually since you mentioned that this is for animations you are creating - drive everything with a curve value.
Through the animation have a curve print out the rotation value you want to have used, and combine rotators to use it.

Then you can simply control the curve in the animation manually which allows you to visually mess with the process to get a better end effect…

Thank you for your message.
It’s first time I’ve created a post on the forum, please understand.

I just added the goal in description, so yes, it’s Rotation Value.
The Rotation Value is actually used with Transform (Modify) Bone (second picture).
Based on the results I figured out Transform (Modify) Bone uses CombineRotators when Add to Existing is used as Rotation Mode.

First picture shows only concept of checking if the Rotation Value is correct (using Rotator A and Rotator B values), so you can use it in any blueprint or even in cpp.

I know you’re trying to help and I appreciate it.
1.
“just Add the 2 rotators togeter” - isn’t that what CombineRotators does?
I’ve tried breaking the rotators and taking away the values to find difference between A and B, but it doesn’t work with Combine Rotators as it’s not the correct way to calculate Rotation Value. I used InvertRotator and Delta (Rotator) even if I don’t understand what they do. I also tried rotating along axis and lerping, but these provide rotators (end value) not the rotation value.

A) No it’s not normal when leg supposed to go forward and goes to a side.
B) Both lerp and timeline will provide rotators (end results) but not the Rotation Value.
C) I used curves to map or scale values (end results) but not to calculate anything (based on 2 variables). Can you please explain how to use it for calculating rotation?

In your initial example, could the issue be you aren’t taking into account the origin position of the additional bone rotation?
Copy bone overrides that rotation, so the position has to be stored before copy bone takes place.

In fact. Scrap copy bone alltogeter, it’s just going to make matters worse.

Take the bone transform from BP, manipulate the rotator part, and use the transform to position the bone with a modify bone node.


Re the rest.
Lerp is meant to work over time via an alpha value.

To get it working the alpha has to go from 0 to 1 to transition from A to B.

You can drive this alpha with a multitude of things, but you still need to feed it an increasing value over time for it to work.


No, as I said, combine rotators converts to fQuat first.
Normally that’s a good thing.
In your scenario it’s not really necessary. Which means you can literally add the 2 as you would a vector.


The rotation value is actually the delta between start and current rotation.

In practice, think of a rotator as a vector 3. Each axis has a value of some value in some format that instead of describing position describes an angle value (rotation). Euler I believe. But that’s just complicating things.

Take Z as an example. A rot of 0,0,180 means that the object is spun on its (local) Z axis by 180 units (degrees).

If that’s the start position and I want to know how much rotation has happened now, when the value is at 0,0,90

I can do 180-90 = 90.

If the value was added and the current is 0,0,270

I can do 180-270=-90.

Now, when you rotate stuff in 3d space, calculations will never be that straightforward. So the delta function should come in handy for you.
But at a base level this should be what it does…


Re the curves.
You can do whatever with them, they are arbitrary values you can set up in editor or in a DCC.
You can literally just output 0 to 90 over the course of an animation and add that value to the rotation of a bone manually…

Anyway, go back to the first thing on this post.
Figure out the best way to feed a single variable to the bone to handle everything.
You may be able to do this without breaking the fastpath optimization either, though it may require separate loc,rot,scale.

Remember that when dealing with animations things happen repeatedly over time and you do need to account for it. So order of operations also matters a lot.

Thank you MostHost_La for your time. Unfortunately your responses didn’t help much. But conversation with you allowed me rethink my problem again. And after a bit of researching I found solution on another forum.

For anyone interested…
To calculate rotation value required for CombineRotator use the following cpp code:
return FRotator(quatb * Inverse(quata));
Where quata and quatb are converted FRotators to FQuats.

1 Like