I don’t know.
It could be for people that are new to Unreal but not new to game development. Not every engine has an equivalent of GetActorForwardVector()
By showing them the lower-level approach, those developers may have a better understanding of what’s going on.
May have been better if they listed the GetActorForwardVector solution just below it.
In the tutorial they are getting the forward direction from the controllers rotation ( XY plane specifically ), that is not the same as the actors forward vector ( XYZ normalized ). The actor can be looking one way and the controller another independently with player input.
Because in this case they are constantly updating the RootComponent of the pawn so they should be the same. RootComponent transforms = Actor transforms.
// Create an instance of our movement component, and tell it to update the root.
OurMovementComponent = CreateDefaultSubobject<UCollidingPawnMovementComponent>(TEXT("CustomMovementComponent"));
OurMovementComponent->UpdatedComponent = RootComponent;
In the first tutorial, the author calculates the direction from the transform of APlayerController via GetControlRotation() and matrix rotation while in the second tutorial, the author calculates the direction from the transform of ACharacter via GetActorForwardVector().
When APlayerController possesses ACharacter, are their transforms identical? If not, how are their transforms related?
They are not. Characters are a “physical” representation of the player in the world whilst the controller is the wil of the player over that character. A quick example is the third person template: camera is set to rotate same as controller, but the character is independent allowing you to move the camera freely without rotating the character.
ACharacteris a subclass of the Pawn class, thus can be possessed.
Now on how do they relate:
Pawn
A Pawn is an Actor that can be an “agent” within the world. Pawns can be possessed by a Controller, they are set up to easily accept input, and they can do various and sundry other player-like things. Note that a Pawn is not assumed to be humanoid.
Controller
Controller is an Actor that is responsible for directing a Pawn. They typically come in 2 flavors, AIController and PlayerController. A controller can “possess” a Pawn to take control of it.
PlayerController
A PlayerController is the interface between the Pawn and the human player controlling it. The PlayerController essentially represents the human player’s will.
In the first tutorial I found the author chose DirA but in another tutorial I found another author (maybe different person) chose DirB. For me it is confusing because DirA is not exactly identical to DirB (I have compared their numerical values which are not identical). Are both approaches correct? So in the future, which approach should I use?
This is one of those questions where you need in the tutorial to show the different camera settings and rotations vs what the player allows, and see the difference between the RotationMatrix and the GetForwardVector() piece.
I know the tutorial you are using, it made me have the same question.