AutoPossessPlayer on playercontroller

i need to know what the equivalent to AutoPossessPlayer = EAutoReceiveInput::Player0; is for a player controller class.
I have used AutoPossessPlayer = EAutoReceiveInput::Player0; on a character class to make that character the main Player, now i need a way to do the same thing but with a playercontroller class.

Hello,

PlayerController class provides a getter method GetCharacter() for this. With it, you can get the Character, attached to the PlayerController and access the needed field AutoPossessPlayer. Your code will look like this:
GetCharacter()->AutoPossessPlayer = EAutoReceiveInput::Player0;

Hope this helped!
Cheers!

it compiles properly but crashes when played.

For safe call of GetCharacter(), you can check whether the function actually returned an appropriate value (not NULL):

ACharacter* CharacterObject = GetCharacter();
	if (CharacterObject) {
		CharacterObject->AutoPossessPlayer = EAutoReceiveInput::Player0;
}

Please note, that you need to have a Character, attached to the PlayerController (possessed by it) for GetCharacter() to work properly. Otherwise, there is no Character to return.

Good luck!

how would i go about attaching a character to the player controller?
would it be my custom Character class i attach or a default one?
where would i then be handling the movement input?
and which would i spawn the character or the player controller?

In the situation where PlayerController possesses Character, they keep references to each other. Since you have decided to use PlayerController, input should be handled in this class. Regarding the Character class, I assume it’s better for you to create your custom class that inherits from Character. This way, you will be able to implement some additional functionality later. (Please note that some new needs may appear in the process of development).

As for the last question, both objects should be spawned. When input is implemented in PlayerController, you can use one PlayerController instance for different Characters with common input functionality.

Hope this helped!
Cheers!