I’m having a nerve-racking problem in my project regarding object rotation.
I have an actor on my level.
This actor has two static mesh components inside it, let’s call them A and B. A is the parent of B.
Below B there are multiple camera components which I can choose during gameplay. So it is something like:
| A
| B
| Camera1
| Camera2
When I start my game, I’m controlling these cameras with an HTC Vive controller.
The controller changes the position and location of the B component (so it can change all cameras).
The problem comes below.
I’m placing another actor in the level to serve as a “starting point” for the camera.
I’m setting it up in the A component above by referencing it, so its values affect the children cameras.
However, when using the Vive controller, its starting location and rotation are not equal to the starting point’s ones, so I’m using a keyboard event to match B’s location and rotation to A’s.
The problem is the rotation doesn’t match.
I’m splitting both components’ rotators and subtracting each one of their axis to build the difference rotator, which I’m then adding in the keyboard event with the Add World Rotation node.
Example with random values:
A's rotation: 50, 40, 30
B's rotation: 15, 25, 5
Calculated difference: 35, 15, 25
B's rotation after adding the difference: something like 45.3543, 42.2547, 25.3854
The difference seems to be properly calculated, but the add world rotation node kind of messes the final result.
What am I doing wrong? Is there any other way to make these rotations match?
Thank you in advance for your help!