Rotation Clarification

I am hoping for some clarification regarding rotating the statue in the game.

In this lecture, Sam originally sets the grab rotation based on HitResult.GetComponent()->GetComponentRotation() but later changes it to simply GetComponentRotation().

Can you clarify why he made this change? It seems confusing to me because I would think that getting the gargoyle’s current transform should keep the gargoyle’s rotation as-is. Instead, the first code sample seems to point the gargoyle in the direction of the world x-axis, whereas as shown in the second code sample, getting the rotation of the grabber causes the rotation of the gargoyle to stay the same.

The rotation you use for grabbing will be used as the initial rotation of the grabbed object. This is used in the calculation of SetTarget....

So if you use the hit component’s rotation for the grab and then used the grabber’s rotation in SetTarget then the grabbed object should always be facing away from you to match the grabber’s rotation … well it would be if the gargoyle mesh faced in the X-axis; if you look at the mesh in the static mesh editor you will see that it is facing in the Y-axis.

If you use the grabber’s rotation for both it should stay looking the same rotation relative to you as you are using the same rotation.

When you state the original rotation is "used in the calculation of SetTarget ", do you mean that GrabComponentAtLocationWithRotation sets the rotation of the object relative to the world (which causes our gargoyle to point towards the y-axis), while SetTarget sets that rotation to be relative to the player (so it will appear to point in that same direction when the player moves while carrying it)?

I mean that the rotation used in SetTarget will be the delta between that and the GrabRotation

Example:
Actor’s rotation is 90 degrees
Player’s is 0

Using the actor’s rotation for grab and the player’s for SetTarget. The actor will rotate -90 degrees.
Using the player’s rotation for both grab and SetTarget, the actor will not rotate at all, it’s already at the target rotation.

I see. I tested out the concept that the actor will not rotate by setting an FRotator to the grab rotation of the gargoyle, and using this rotation in the SetTarget function. Since SetTarget uses the delta between the two rotations, there is no actual change. Neat! Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms