Axis-Angle rotation in a game

Hi.

I have an object in the location (-820, 0, 500), and it is rotated with this rotator (0, -30, 0) because the object is a camera that it is facing to the origin to the coordinate system.

I want to move the camera around the origin and rotate it to make it face always the origin of the coordinate system.

To do it, there is a function in Unreal named Rotate Vector Around Axis with three input arguments:

  • InVector: I suppose this is the vector I want to rotate.
  • Angle: the angle I want to rotate.
  • Axis: an unit vector with the axis on which I want to rotate.

I think that the Axis should be (0, 0, 1) but I donā€™t know which is the value for the argument InVector.

If want to move the object in the location (-820, 0, 500) around the origin (0, 0, 0) and rotate it to make it always face to the origin, what values do I have to use?

I think this is the problem of rotating and object around an axis that I have found in the video ā€œMath for Game Developers - Axis-Angle Rotationā€.

Thanks.

In vector is (-820, 0, 500)

Rotating this will give you the next location, I -think- it will work with the camera rotation value.

1 Like

If I use (-820, 0, 500) as the value of In Vect I get this output:

I think that the Y coordinate should be smaller.

Have you looked into the ā€œFind Look at Rotationā€ node?

Iā€™m not sure if you need to normalize before using the nodeā€¦ Have you actually tried the rotation?

1 Like

This is what I have tried:

Thatā€™s going to mess up the rotation, because itā€™s world rotation will be very different as it moves around.

Try just setting the location.

Or, as @RecourseDesign says, use ā€˜look at rotationā€™ ( just the Z ) to face the origin.

1 Like

With this:

I get the following input to SetActorLocation:

X=-821.682 Y=-0.297 Z=501.041
X=-822.522 Y=-0.445 Z=501.562
X=-823.363 Y=-0.594 Z=502.082
X=-824.204 Y=-0.743 Z=502.603
ā€¦
X=-830.088 Y=-1.789 Z=506.248
X=-830.928 Y=-1.939 Z=506.768
X=-831.769 Y=-2.089 Z=507.289
ā€¦
X=-835.971 Y=-2.843 Z=509.893
X=-836.811 Y=-2.994 Z=510.413
X=-837.651 Y=-3.145 Z=510.934
ā€¦
X=-841.012 Y=-3.752 Z=513.017
X=-841.852 Y=-3.903 Z=513.538
X=-842.692 Y=-4.056 Z=514.058
ā€¦
X=-846.052 Y=-4.666 Z=516.142
X=-846.892 Y=-4.819 Z=516.662
X=-847.731 Y=-4.972 Z=517.183
ā€¦
X=-851.091 Y=-5.585 Z=519.266
X=-851.930 Y=-5.739 Z=519.787
X=-852.770 Y=-5.893 Z=520.308
ā€¦
X=-856.128 Y=-6.510 Z=522.391
X=-856.968 Y=-6.664 Z=522.912
X=-857.807 Y=-6.819 Z=523.433
X=-858.647 Y=-6.974 Z=523.954
X=-859.486 Y=-7.129 Z=524.475
X=-860.326 Y=-7.284 Z=524.996
X=-861.165 Y=-7.440 Z=525.517

I read all that and can immediately see the problem - NOT :wink:

I think itā€™s the normalized vector problem, but Iā€™m not at a machine at the mo. Will get back.

1 Like

I think the problem is with the In Vect. In this video, Unreal Engine 4 C++ Tutorial: Rotate Actor Around Player - YouTube, it works but I donā€™t know how to figure which is the In Vect value.

In the video, he uses (300, 0, 0) to make the object move around the player at 300 unit distance and in the same value of Z.

Just thinking outside the square, what about instead of directly having the camera in your scene, you create a blueprint with a camera attached to a spring-arm - then you can just rotate that around and change itā€™s lengthā€¦

cam

2 Likes

I think you are right here: I have to use the vector (-820, 0, 500).

The problem I have now is that the camera doesnā€™t rotate. In the video, he uses a FQuat.

How can I make a FQuat using a Rotator in Blueprints?

Thanks.

Solution is aboveā€¦ ( @ViaCognita )

1 Like