UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Controller.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "UObject/CoreNet.h"
9#include "Controller.generated.h"
10
11class ACharacter;
12class APawn;
13class APlayerState;
15class UDamageType;
16
17UDELEGATE(BlueprintAuthorityOnly)
21
39UCLASS(abstract, notplaceable, NotBlueprintable, HideCategories=(Collision,Rendering,Transformation), MinimalAPI)
41{
43
44public:
47
49 UPROPERTY(replicatedUsing = OnRep_PlayerState, BlueprintReadOnly, Category=Controller)
51 ENGINE_API void SetPlayerState(APlayerState* InPlayerState);
52
54 TWeakObjectPtr<class AActor> StartSpot;
55
57 UPROPERTY(BlueprintAssignable)
58 FInstigatedAnyDamageSignature OnInstigatedAnyDamage;
59
61 UPROPERTY(BlueprintAssignable, Category=Pawn)
62 FOnPossessedPawnChanged OnPossessedPawnChanged;
63
65 UPROPERTY()
66 FName StateName;
67
70 UPROPERTY(replicatedUsing=OnRep_Pawn)
71 TObjectPtr<APawn> Pawn;
72 void SetPawn_Direct(APawn* InPawn);
73
78 TWeakObjectPtr< APawn > OldPawn;
79
81 UPROPERTY()
83
85 UPROPERTY()
86 TObjectPtr<USceneComponent> TransformComponent;
87
91
93 UPROPERTY()
94 FRotator ControlRotation;
95
97 ENGINE_API bool IsValidControlRotation(FRotator CheckRotation) const;
98
105 UPROPERTY(EditDefaultsOnly, Category="Controller|Transform")
106 uint8 bAttachToPawn:1;
107
109 uint8 bIsPlayerController:1;
110
112 uint8 bCanPossessWithoutAuthority:1;
113
115 uint8 IgnoreMoveInput;
116
118 uint8 IgnoreLookInput;
119
125 ENGINE_API virtual void AttachToPawn(APawn* InPawn);
126
128 ENGINE_API virtual void DetachFromPawn();
129
131 ENGINE_API virtual void AddPawnTickDependency(APawn* NewPawn);
132
134 ENGINE_API virtual void RemovePawnTickDependency(APawn* InOldPawn);
135
137 class USceneComponent* GetTransformComponent() const { return TransformComponent; }
138
139public:
140
142 ENGINE_API virtual void ChangeState(FName NewState);
143
149 ENGINE_API bool IsInState(FName InStateName) const;
150
152 ENGINE_API FName GetStateName() const;
153
158 UFUNCTION(BlueprintCallable, Category=Pawn)
159 ENGINE_API virtual FRotator GetControlRotation() const;
160
162 UFUNCTION(BlueprintCallable, Category=Pawn, meta=(Tooltip="Set the control rotation."))
163 ENGINE_API virtual void SetControlRotation(const FRotator& NewRotation);
164
166 UFUNCTION(BlueprintCallable, Category=Pawn)
167 ENGINE_API virtual void SetInitialLocationAndRotation(const FVector& NewLocation, const FRotator& NewRotation);
168
169
177 UFUNCTION(BlueprintCallable, Category=Controller)
178 ENGINE_API virtual bool LineOfSightTo(const class AActor* Other, FVector ViewPoint = FVector(ForceInit), bool bAlternateChecks = false) const;
179
181 UFUNCTION()
182 ENGINE_API virtual void OnRep_Pawn();
183
184 UFUNCTION()
185 ENGINE_API virtual void OnRep_PlayerState();
186
191 template < class T >
192 T* GetPlayerState() const
193 {
194 return Cast<T>(PlayerState);
195 }
196
198 UFUNCTION(Reliable, Client, WithValidation)
199 ENGINE_API void ClientSetLocation(FVector NewLocation, FRotator NewRotation);
200
202 UFUNCTION(Reliable, Client, WithValidation)
203 ENGINE_API void ClientSetRotation(FRotator NewRotation, bool bResetCamera = false);
204
206 UFUNCTION(BlueprintCallable, Category=Pawn, meta=(DisplayName="Get Controlled Pawn", ScriptName="GetControlledPawn"))
207 ENGINE_API APawn* K2_GetPawn() const;
208
209 FPawnChangedSignature& GetOnNewPawnNotifier() { return OnNewPawn; }
210
211public:
212
214
215 //~ Begin AActor Interface
216 ENGINE_API virtual void TickActor( float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction ) override;
217 ENGINE_API virtual void K2_DestroyActor() override;
218 ENGINE_API virtual void DisplayDebug(class UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) override;
219 ENGINE_API virtual void GetActorEyesViewPoint( FVector& out_Location, FRotator& out_Rotation ) const override;
220 ENGINE_API virtual FString GetHumanReadableName() const override;
221
223 ENGINE_API virtual void PostInitializeComponents() override;
224
225 ENGINE_API virtual void Reset() override;
226 ENGINE_API virtual void Destroyed() override;
227 //~ End AActor Interface
228
230 inline TObjectPtr<APawn> GetPawn() const { return Pawn; }
231
233 template<class T>
234 T* GetPawn() const
235 {
236 return Cast<T>(Pawn);
237 }
238
240 inline ACharacter* GetCharacter() const { return Character; }
241
243 ENGINE_API virtual void SetPawn(APawn* InPawn);
244
246 ENGINE_API void SetPawnFromRep(APawn* InPawn);
247
249 UFUNCTION(BlueprintCallable, Category=Pawn)
250 ENGINE_API virtual AActor* GetViewTarget() const;
251
253 UFUNCTION(BlueprintCallable, Category=Pawn)
254 ENGINE_API virtual FRotator GetDesiredRotation() const;
255
257 UFUNCTION(BlueprintCallable, Category=Pawn)
258 bool IsPlayerController() const;
259
261 UFUNCTION(BlueprintCallable, Category=Pawn)
262 bool IsLocalPlayerController() const;
263
265 UFUNCTION(BlueprintCallable, Category=Pawn)
266 ENGINE_API virtual bool IsLocalController() const;
267
269 ENGINE_API virtual void CleanupPlayerState();
270
280 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Pawn, meta=(Keywords="set controller"))
281 ENGINE_API virtual void Possess(APawn* InPawn) final; // DEPRECATED(4.22, "Possess is marked virtual final as you should now be overriding OnPossess instead")
282
284 UFUNCTION(BlueprintCallable, Category=Pawn, meta=(Keywords="set controller"))
285 ENGINE_API virtual void UnPossess() final; // DEPRECATED(4.22, "Possess is marked virtual final as you should now be overriding OnUnPossess instead")
286
289 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On Possess"))
290 ENGINE_API void ReceivePossess(APawn* PossessedPawn);
291
296 ENGINE_API virtual void OnPossess(APawn* InPawn);
297
299 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "On UnPossess"))
300 ENGINE_API void ReceiveUnPossess(APawn* UnpossessedPawn);
301
303 ENGINE_API virtual void OnUnPossess();
304
305public:
310 ENGINE_API virtual void PawnPendingDestroy(APawn* inPawn);
311
313 ENGINE_API virtual void InstigatedAnyDamage(float Damage, const class UDamageType* DamageType, class AActor* DamagedActor, class AActor* DamageCauser);
314
316 ENGINE_API virtual void InitPlayerState();
317
323 ENGINE_API virtual void GameHasEnded(class AActor* EndGameFocus = nullptr, bool bIsWinner = false);
324
333 UFUNCTION(BlueprintCallable, Category = Pawn)
334 ENGINE_API virtual void GetPlayerViewPoint( FVector& Location, FRotator& Rotation ) const;
335
337 ENGINE_API virtual void FailedToSpawnPawn();
338
339 //~ Begin INavAgentInterface Interface
340 ENGINE_API virtual const struct FNavAgentProperties& GetNavAgentPropertiesRef() const override;
341 ENGINE_API virtual FVector GetNavAgentLocation() const override;
342 ENGINE_API virtual void GetMoveGoalReachTest(const AActor* MovingActor, const FVector& MoveOffset, FVector& GoalOffset, float& GoalRadius, float& GoalHalfHeight) const override;
343 ENGINE_API virtual bool ShouldPostponePathUpdates() const override;
344 ENGINE_API virtual bool IsFollowingAPath() const override;
345 ENGINE_API virtual IPathFollowingAgentInterface* GetPathFollowingAgent() const override;
346 //~ End INavAgentInterface Interface
347
349 UFUNCTION(BlueprintCallable, Category="AI|Navigation")
350 ENGINE_API virtual void StopMovement();
351
356 UFUNCTION(BlueprintCallable, Category=Input)
357 ENGINE_API virtual void SetIgnoreMoveInput(bool bNewMoveInput);
358
360 UFUNCTION(BlueprintCallable, Category=Input, meta=(Keywords = "ClearIgnoreMoveInput"))
361 ENGINE_API virtual void ResetIgnoreMoveInput();
362
364 UFUNCTION(BlueprintCallable, Category=Input)
365 ENGINE_API virtual bool IsMoveInputIgnored() const;
366
371 UFUNCTION(BlueprintCallable, Category=Input)
372 ENGINE_API virtual void SetIgnoreLookInput(bool bNewLookInput);
373
375 UFUNCTION(BlueprintCallable, Category=Input, meta=(Keywords="ClearIgnoreLookInput"))
376 ENGINE_API virtual void ResetIgnoreLookInput();
377
379 UFUNCTION(BlueprintCallable, Category=Input)
380 ENGINE_API virtual bool IsLookInputIgnored() const;
381
383 UFUNCTION(BlueprintCallable, Category=Input)
384 ENGINE_API virtual void ResetIgnoreInputFlags();
385
387 ENGINE_API virtual void CurrentLevelUnloaded();
388
390 ENGINE_API virtual bool ShouldParticipateInSeamlessTravel() const;
391
394 ENGINE_API virtual void BeginInactiveState();
395
397 ENGINE_API virtual void EndInactiveState();
398
400 UFUNCTION(BlueprintImplementableEvent, BlueprintAuthorityOnly)
401 ENGINE_API void ReceiveInstigatedAnyDamage(float Damage, const class UDamageType* DamageType, class AActor* DamagedActor, class AActor* DamageCauser);
402
403private:
404 // Hidden functions that don't make sense to use on this class.
406
407};
408
409
410// INLINES
411
412inline bool AController::IsPlayerController() const
413{
414 return bIsPlayerController;
415}
416
418{
420}
#define HIDE_ACTOR_TRANSFORM_FUNCTIONS()
Definition Actor.h:5033
@ ForceInit
Definition CoreMiscDefines.h:155
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param1Name, Param2Type, Param2Name)
Definition DelegateCombinations.h:62
#define DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(DelegateName, Param1Type, Param1Name, Param2Type, Param2Name, Param3Type, Param3Name, Param4Type, Param4Name)
Definition DelegateCombinations.h:80
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
ELevelTick
Definition EngineBaseTypes.h:70
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UDELEGATE(...)
Definition ObjectMacros.h:750
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Actor.h:257
Definition Character.h:242
Definition Controller.h:41
TObjectPtr< APawn > GetPawn() const
Definition Controller.h:230
T * GetPawn() const
Definition Controller.h:234
ACharacter * GetCharacter() const
Definition Controller.h:240
virtual ENGINE_API bool IsLocalController() const
Definition Controller.cpp:86
bool IsLocalPlayerController() const
Definition Controller.h:417
bool IsPlayerController() const
Definition Controller.h:412
Definition PlayerState.h:42
Definition DisplayDebugHelpers.h:9
Definition NameTypes.h:617
Definition UObjectGlobals.h:1292
static COREUOBJECT_API FObjectInitializer & Get()
Definition UObjectGlobals.cpp:5001
Definition NavAgentInterface.h:20
Definition PathFollowingAgentInterface.h:21
Definition Array.h:670
Definition Canvas.h:159
Definition DamageType.h:21
virtual COREUOBJECT_API void GetLifetimeReplicatedProps(TArray< class FLifetimeProperty > &OutLifetimeProps) const
Definition Obj.cpp:5874
@ false
Definition radaudio_common.h:23
Definition EngineBaseTypes.h:526
Definition NavigationTypes.h:453
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25