I'm new to UE4 and am trying to understand some basics concepts around controlling a character pawn. I'm fumbling around trying to implement some character movement logic. I'm going for the basic WASD to move the character forward, back, side to side - like in pretty much every basic first person shooter. I also want the mouse input to rotate the character around.
I've got my own custom PlayerController
and Character
classes.
Adding the code to move the character around - front, back, sideways - seems to all go in the character class itself. There is a method in there called AddMovementInput that appears to modify the position for me. This also makes me think that the character class "owns" its own location. That makes sense because there could be more than one character class at a time, each at different locations, right?
Adding the code to rotate the character has similar methods for controlling rotation - AddControllerYawInput
, AddControllerPitchInput
, AddControllerRollInput
. Simply looking at the names of the functions suggests that the yaw pitch and roll are "owned" by the player controller. Looking at the docs and comments for the functions further backs that up: "Add input (affecting Yaw) to the Controller's ControlRotation, if it is a local PlayerController." So it would seem, to me, that the yaw pitch and roll are values "owned" by the player controller, right?
As a beginner, this confuses me: I'm confused by the fact that the location is stored in the character itself but the rotation doesn't seem to be.
I am interested to learn how I should "think about" character or pawn movement. I'm just unclear on it and it's causing me to get hung up on the topic.