So the way I gather it, the advised way to do things is to have input handled by the player controller, then the Pawn/Character class on the object will handle turning that input into actual motion/whatever.
So my question is: say my player object has a PlayerController component and a Character component. I have a “MoveForward” method on the Character class, and I want to bind the “MoveForward” control axis to that method. But I want to do so within the PlayerController class. So how do I get a reference to the character which is on the player’s object, so that I can pass it to BindAxis? Basically I want something along the lines of:
In PlayerController:
void PlayerController::SetupPlayerInputComponent(class UInputComponent* inputComponent)
{
ACharacter* pointerToThisObjectsCharComponent = Actor.GetComponent(ACharacter);
inputComponent->BindAxis("MoveForward", pointerToThisObjectsCharComponent, &ACharacter::MoveForward); //binds the "MoveForward" axis to this character's MoveForward method.
}
How do I do this?
Thank you for any replies.