ACharacter::SetupPlayerInputComponent
#include "GameFramework/Character.h"
Access: public
Specifiers: virtualoverride
Description
Called to bind input actions and axes to the character's input component. Override this to wire movement and action bindings for a player-controlled character.
Caveats & Gotchas
- • Called only when the pawn is possessed by a player controller — AI-controlled characters never have this called. Do not rely on it for logic that should run for all characters.
- • With Enhanced Input, bind to UEnhancedInputComponent instead of the base UInputComponent — cast PlayerInputComponent to UEnhancedInputComponent before binding.
Signature
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PlayerInputComponent | UInputComponent* | The input component to bind actions and axes to. Never null when this function is called. | — |
Return Type
void Example
Bind movement with Enhanced Input C++
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
UEnhancedInputComponent* EIC = CastChecked<UEnhancedInputComponent>(PlayerInputComponent);
EIC->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AMyCharacter::Move);
EIC->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
EIC->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?