AActor::InputComponent
#include "GameFramework/Actor.h"
Access: public
Specifiers: UPROPERTYDuplicateTransient
Description
The UInputComponent that handles input bindings for this actor when input is enabled. Null until EnableInput() is called, which creates and registers it.
Caveats & Gotchas
- • This is null by default and only populated after EnableInput() is called for this actor. Attempting to bind inputs before EnableInput() will crash.
- • Marked DuplicateTransient, so it is not copied when the actor is duplicated (e.g. via Duplicate In Editor). Each actor instance must have EnableInput() called independently.
Signature
UPROPERTY(DuplicateTransient)
TObjectPtr<class UInputComponent> InputComponent Example
Bind an action after enabling input C++
void AMyActor::EnablePlayerInput(APlayerController* PC)
{
EnableInput(PC);
// InputComponent is now valid
InputComponent->BindAction("Interact", IE_Pressed, this, &AMyActor::OnInteract);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?