BindAction in PlayerController or PlayerCharacter

a very simple question…
I would like to make one rts game and a bit confused where should i BindAction…
In the fps template, the gameplay key bindings is set up int the Character.cpp. But in Top Down template, the setup is made in the PlayerController.cpp.
I am wondering any difference btw them, which is better? or maybe depend on the game type?

Hey,

the best way to bind the Input is in the SetupPlayerInputComponent Method of your ACharacter.

Example:

void AMyCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

	check(InputComponent);

	InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
}

Thanks for the reply~
So what should be written in the PlayerController?..

Let’s say you have 2 Characters and you can switch ingame between them.

A Knight and a Wizard.
Both share only ONE PlayerController.

The Knight can do a SwordAttack when SPACE is Pressed

The Wizard can do a MagicAttack when E is Pressed

So there are two different ActionBindings

Each Character binds his own Actions to his InputComponent.

Ok now we want both to be able to jump when W is Pressed.
This bindings is the same for both so we can bind this in our PlayerController because the Controller does not change in runtime.

I hope I could explain it.
My english is not the best :slight_smile:

Good Luck

Greetings

understand! thank you so much !